mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02: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 messageObj
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return { node, meta: { id } }
|
||||||
node,
|
|
||||||
meta: { id },
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
].filter(Boolean)
|
].filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,11 @@ import { Message } from '../types'
|
||||||
export function getObjFromExpression(exprNode: ObjectExpression) {
|
export function getObjFromExpression(exprNode: ObjectExpression) {
|
||||||
return exprNode.properties.reduce<Message>(
|
return exprNode.properties.reduce<Message>(
|
||||||
(acc, prop: Property) => {
|
(acc, prop: Property) => {
|
||||||
if (prop.value.type !== 'Literal') return acc
|
|
||||||
// we only want primitives
|
// 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
|
const key = (prop.key as Identifier).name as string
|
||||||
acc.meta[key] = prop.value.value
|
acc.meta[key] = prop.value.value
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,12 @@ import {
|
||||||
} from '../../src/cli/extract'
|
} from '../../src/cli/extract'
|
||||||
|
|
||||||
describe('collecting format calls', () => {
|
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', () => {
|
test('returns nothing if there are no imports', () => {
|
||||||
const ast = parse(`<script>
|
const ast = parse(`<script>
|
||||||
import Foo from 'foo';
|
import Foo from 'foo';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user