diff --git a/package.json b/package.json index e69913f4..cb330800 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "lint-staged": "^8.1.7", "prettier": "^1.17.1", "vee-validate": "^2.2.9", + "vue-i18n": "^8.12.0", "vue-jest": "^3.0.4", "vue-router": "^3.0.6", "vuex": "^3.1.1" diff --git a/tests/__tests__/components/VueI18n.vue b/tests/__tests__/components/VueI18n.vue new file mode 100644 index 00000000..582ca482 --- /dev/null +++ b/tests/__tests__/components/VueI18n.vue @@ -0,0 +1,21 @@ + + + diff --git a/tests/__tests__/vueI18n.js b/tests/__tests__/vueI18n.js new file mode 100644 index 00000000..58c3de6e --- /dev/null +++ b/tests/__tests__/vueI18n.js @@ -0,0 +1,29 @@ +import 'jest-dom/extend-expect' +import { cleanup, render, fireEvent } from '@testing-library/vue' +import Vuei18n from 'vue-i18n' +import VueI18n from './components/VueI18n' + +afterEach(cleanup) + +const ja = { + Hello: 'こんにちは' +} + +test('can render en and ja text in header', async () => { + const { queryByTestId, getByTestId } = render(VueI18n, {}, vue => { + vue.use(Vuei18n) + const i18n = new Vuei18n({ + locale: 'en', + messages: { + ja + } + }) + return { i18n } + }) + + expect(queryByTestId('section-header')).toHaveTextContent('Hello') + + await fireEvent.click(getByTestId('button-ja')) + + expect(queryByTestId('section-header')).toHaveTextContent('こんにちは') +})