|
1 | | -test.todo('Your test suite must contain at least one test.') |
2 | | - |
3 | | -// import '@testing-library/jest-dom' |
4 | | -// import {render, fireEvent} from '@testing-library/vue' |
5 | | -// import Vuei18n from 'vue-i18n' |
6 | | -// import Translations from './components/Translations' |
7 | | - |
8 | | -// const messages = { |
9 | | -// en: { |
10 | | -// Hello: 'Hello', |
11 | | -// }, |
12 | | -// ja: { |
13 | | -// Hello: 'こんにちは', |
14 | | -// }, |
15 | | -// } |
16 | | - |
17 | | -// test('renders translations', async () => { |
18 | | -// const {queryByText, getByText} = render(Translations, {}, vue => { |
19 | | -// // Let's register and configure Vuei18n normally |
20 | | -// vue.use(Vuei18n) |
21 | | - |
22 | | -// const i18n = new Vuei18n({ |
23 | | -// locale: 'en', |
24 | | -// fallbackLocale: 'en', |
25 | | -// messages, |
26 | | -// }) |
27 | | - |
28 | | -// // Notice how we return an object from the callback function. It will be |
29 | | -// // merged as an additional option on the created Vue instance. |
30 | | -// return { |
31 | | -// i18n, |
32 | | -// } |
33 | | -// }) |
34 | | - |
35 | | -// expect(getByText('Hello')).toBeInTheDocument() |
36 | | - |
37 | | -// await fireEvent.click(getByText('Japanese')) |
38 | | - |
39 | | -// expect(getByText('こんにちは')).toBeInTheDocument() |
40 | | - |
41 | | -// expect(queryByText('Hello')).toBeNull() |
42 | | -// }) |
| 1 | + import '@testing-library/jest-dom' |
| 2 | + import {render, fireEvent} from '@testing-library/vue' |
| 3 | + import {createI18n} from 'vue-i18n' |
| 4 | + import Translations from './components/Translations' |
| 5 | + |
| 6 | + const i18n = createI18n({ |
| 7 | + legacy: true, |
| 8 | + locale: 'en', |
| 9 | + messages: { |
| 10 | + en: { |
| 11 | + hello: 'Hello', |
| 12 | + }, |
| 13 | + ja: { |
| 14 | + hello: 'こんにちは', |
| 15 | + }, |
| 16 | + }, |
| 17 | + }) |
| 18 | + |
| 19 | + test('renders translations', async () => { |
| 20 | + const {queryByText, getByText} = render(Translations, { |
| 21 | + global: { |
| 22 | + plugins: [i18n] |
| 23 | + } |
| 24 | + }) |
| 25 | + |
| 26 | + expect(getByText('Hello')).toBeInTheDocument() |
| 27 | + |
| 28 | + await fireEvent.update(getByText('Japanese')) |
| 29 | + |
| 30 | + expect(getByText('こんにちは')).toBeInTheDocument() |
| 31 | + |
| 32 | + expect(queryByText('Hello')).toBeNull() |
| 33 | + }) |
0 commit comments