-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathvueI18n.js
38 lines (30 loc) · 922 Bytes
/
vueI18n.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
import '@testing-library/jest-dom/extend-expect'
import {render, fireEvent} from '@testing-library/vue'
import Vuei18n from 'vue-i18n'
import VueI18n from './components/VueI18n'
const messages = {
en: {
Hello: 'Hello',
},
ja: {
Hello: 'こんにちは',
},
}
test('renders translations', async () => {
const {queryByText, getByText} = render(VueI18n, {}, vue => {
// Let's register 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
// available 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')).toBeNull()
})