Skip to content

Commit 1b9711a

Browse files
committed
refactor: separate issue bug fixing tests
1 parent e941946 commit 1b9711a

File tree

3 files changed

+354
-247
lines changed

3 files changed

+354
-247
lines changed

packages/vue-i18n-core/test/components/Translation.test.ts

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -321,89 +321,3 @@ test('v-if / v-else', async () => {
321321
`<p class="name">hello, <span>kazu_pon</span>!</p>`
322322
)
323323
})
324-
325-
test('v-for: issue #819', async () => {
326-
const i18n = createI18n({
327-
legacy: false,
328-
locale: 'en',
329-
messages
330-
})
331-
332-
const App = defineComponent({
333-
setup() {
334-
useI18n()
335-
const values = ref(['kazupon', 'oranges'])
336-
return { values }
337-
},
338-
template: `
339-
<i18n-t keypath="message.list_multi" locale="en">
340-
<span v-for="(value, index) in values" :key="index" class="bold">
341-
{{ value }}
342-
</span>
343-
</i18n-t>
344-
`
345-
})
346-
const wrapper = await mount(App, i18n)
347-
348-
expect(wrapper.html()).toEqual(
349-
`hello, <span class="bold">kazupon</span>! Do you like <span class="bold">oranges</span>?`
350-
)
351-
})
352-
353-
test('issue #708', async () => {
354-
const i18n = createI18n({
355-
legacy: true,
356-
locale: 'en',
357-
messages
358-
})
359-
360-
const C2 = defineComponent({
361-
template: `<div>C2 slot: <slot></slot></div>`
362-
})
363-
364-
const C1 = defineComponent({
365-
components: {
366-
C2
367-
},
368-
template: `<div>
369-
C1:
370-
<div>{{ $t("hello", { world: $t("world") }) }}</div>
371-
<i18n-t keypath="hello" tag="div">
372-
<template #world>
373-
<strong>{{ $t("world") }}</strong>
374-
</template>
375-
</i18n-t>
376-
377-
<br />
378-
379-
<C2>
380-
<div>{{ $t("hello", { world: $t("world") }) }}</div>
381-
<i18n-t keypath="hello" tag="div">
382-
<template #world>
383-
<strong>{{ $t("world") }}</strong>
384-
</template>
385-
</i18n-t>
386-
</C2>
387-
</div>`,
388-
i18n: {
389-
messages: {
390-
en: {
391-
hello: 'Hello {world}',
392-
world: 'world!'
393-
}
394-
}
395-
}
396-
})
397-
398-
const App = defineComponent({
399-
components: {
400-
C1
401-
},
402-
template: `<C1 />`
403-
})
404-
const wrapper = await mount(App, i18n)
405-
406-
expect(wrapper.html()).toEqual(
407-
`<div> C1: <div>Hello world!</div><div>Hello <strong>world!</strong></div><br><div>C2 slot: <div>Hello world!</div><div>Hello <strong>world!</strong></div></div></div>`
408-
)
409-
})

packages/vue-i18n-core/test/i18n.test.ts

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import {
6-
ref,
76
h,
87
defineComponent,
98
defineCustomElement,
@@ -1009,163 +1008,3 @@ describe('castToVueI18n', () => {
10091008
)
10101009
})
10111010
})
1012-
1013-
describe('issue #722', () => {
1014-
test('legacy', async () => {
1015-
const messages = {
1016-
en: { language: 'English' },
1017-
ja: { language: '日本語' }
1018-
}
1019-
1020-
const i18n = createI18n({
1021-
legacy: true,
1022-
locale: 'en',
1023-
messages
1024-
})
1025-
1026-
const App = defineComponent({
1027-
template: `<transition name="fade">
1028-
<i18n-t keypath="hello" tag="p">
1029-
<template #world>
1030-
<b>{{ $t("world") }}</b>
1031-
</template>
1032-
</i18n-t>
1033-
</transition>`,
1034-
i18n: {
1035-
messages: {
1036-
en: {
1037-
hello: 'Hello {world}',
1038-
world: 'world!'
1039-
}
1040-
}
1041-
}
1042-
})
1043-
const wrapper = await mount(App, i18n)
1044-
1045-
expect(wrapper.html()).toEqual(`<p>Hello <b>world!</b></p>`)
1046-
})
1047-
1048-
test('composition', async () => {
1049-
const messages = {
1050-
en: { language: 'English' },
1051-
ja: { language: '日本語' }
1052-
}
1053-
1054-
const i18n = createI18n({
1055-
legacy: false,
1056-
globalInjection: true,
1057-
locale: 'en',
1058-
messages
1059-
})
1060-
1061-
const App = defineComponent({
1062-
setup() {
1063-
const { t } = useI18n({
1064-
inheritLocale: true,
1065-
messages: {
1066-
en: {
1067-
hello: 'Hello {world}',
1068-
world: 'world!'
1069-
}
1070-
}
1071-
})
1072-
return { t }
1073-
},
1074-
template: `<transition name="fade">
1075-
<i18n-t keypath="hello" tag="p">
1076-
<template #world>
1077-
<b>{{ t("world") }}</b>
1078-
</template>
1079-
</i18n-t>
1080-
</transition>`
1081-
})
1082-
const wrapper = await mount(App, i18n)
1083-
1084-
expect(wrapper.html()).toEqual(`<p>Hello <b>world!</b></p>`)
1085-
})
1086-
1087-
test('v-if: legacy', async () => {
1088-
const messages = {
1089-
en: { language: 'English' },
1090-
ja: { language: '日本語' }
1091-
}
1092-
1093-
const i18n = createI18n({
1094-
legacy: true,
1095-
locale: 'en',
1096-
messages
1097-
})
1098-
1099-
const App = defineComponent({
1100-
data() {
1101-
return { flag: true }
1102-
},
1103-
template: `<div v-if="flag">
1104-
<i18n-t keypath="hello" tag="p">
1105-
<template #world>
1106-
<b>{{ $t("world") }}</b>
1107-
</template>
1108-
</i18n-t>
1109-
</div>`,
1110-
i18n: {
1111-
messages: {
1112-
en: {
1113-
hello: 'Hello {world}',
1114-
world: 'world!'
1115-
}
1116-
}
1117-
}
1118-
})
1119-
const wrapper = await mount(App, i18n)
1120-
1121-
expect(wrapper.html()).toEqual(`<div><p>Hello <b>world!</b></p></div>`)
1122-
})
1123-
1124-
test('v-if: composition', async () => {
1125-
const messages = {
1126-
en: { language: 'English' },
1127-
ja: { language: '日本語' }
1128-
}
1129-
1130-
const i18n = createI18n({
1131-
legacy: false,
1132-
globalInjection: true,
1133-
locale: 'en',
1134-
messages
1135-
})
1136-
1137-
const App = defineComponent({
1138-
setup() {
1139-
const { t } = useI18n({
1140-
inheritLocale: true,
1141-
messages: {
1142-
en: {
1143-
hello: 'Hello {world}',
1144-
world: 'world!'
1145-
}
1146-
}
1147-
})
1148-
const flag = ref(true)
1149-
return { t, flag }
1150-
},
1151-
template: `<div v-if="flag">
1152-
<i18n-t keypath="hello" tag="p">
1153-
<template #world>
1154-
<b>{{ t("world") }}</b>
1155-
</template>
1156-
</i18n-t>
1157-
</div>`,
1158-
i18n: {
1159-
messages: {
1160-
en: {
1161-
hello: 'Hello {world}',
1162-
world: 'world!'
1163-
}
1164-
}
1165-
}
1166-
})
1167-
const wrapper = await mount(App, i18n)
1168-
1169-
expect(wrapper.html()).toEqual(`<div><p>Hello <b>world!</b></p></div>`)
1170-
})
1171-
})

0 commit comments

Comments
 (0)