mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 09:59:58 +01:00
test: 💍 add missing test for component without script
This commit is contained in:
parent
45216d46ea
commit
e08fa29099
@ -150,10 +150,7 @@ export function collectMessages(markup: string): Message[] {
|
||||
return messageObj
|
||||
}
|
||||
|
||||
return {
|
||||
node,
|
||||
meta: { id },
|
||||
}
|
||||
return { node, meta: { id } }
|
||||
}),
|
||||
].filter(Boolean)
|
||||
}
|
||||
|
@ -5,9 +5,11 @@ import { Message } from '../types'
|
||||
export function getObjFromExpression(exprNode: ObjectExpression) {
|
||||
return exprNode.properties.reduce<Message>(
|
||||
(acc, prop: Property) => {
|
||||
if (prop.value.type !== 'Literal') return acc
|
||||
// we only want primitives
|
||||
if (prop.value.value !== Object(prop.value.value)) {
|
||||
if (
|
||||
prop.value.type === 'Literal' &&
|
||||
prop.value.value !== Object(prop.value.value)
|
||||
) {
|
||||
const key = (prop.key as Identifier).name as string
|
||||
acc.meta[key] = prop.value.value
|
||||
}
|
||||
|
@ -10,6 +10,12 @@ import {
|
||||
} from '../../src/cli/extract'
|
||||
|
||||
describe('collecting format calls', () => {
|
||||
test('returns nothing if there are no script tag', () => {
|
||||
const ast = parse(`<div>Hey</div>`)
|
||||
const calls = collectFormatCalls(ast)
|
||||
expect(calls).toHaveLength(0)
|
||||
})
|
||||
|
||||
test('returns nothing if there are no imports', () => {
|
||||
const ast = parse(`<script>
|
||||
import Foo from 'foo';
|
||||
|
Loading…
Reference in New Issue
Block a user