-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathvue-i18n.js
40 lines (32 loc) · 960 Bytes
/
vue-i18n.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import '@testing-library/jest-dom'
import {render, fireEvent} from '@testing-library/vue'
import Vuei18n from 'vue-i18n'
import Translations from './components/Translations'
const messages = {
en: {
Hello: 'Hello',
},
ja: {
Hello: 'こんにちは',
},
}
test('renders translations', async () => {
const {queryByText, getByText} = render(Translations, {}, vue => {
// Let's register and configure Vuei18n normally
vue.use(Vuei18n)
const i18n = new Vuei18n({
locale: 'en',
fallbackLocale: 'en',
messages,
})
// Notice how we return an object from the callback function. It will be
// merged as an additional option on the created Vue instance.
return {
i18n,
}
})
expect(getByText('Hello')).toBeInTheDocument()
await fireEvent.click(getByText('Japanese'))
expect(getByText('こんにちは')).toBeInTheDocument()
expect(queryByText('Hello')).not.toBeInTheDocument()
})