Last active
March 24, 2018 10:27
-
-
Save SoarLin/ca9dbfeb3128dad873e2f4ebe5dfcc12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallow, createLocalVue } from '@vue/test-utils' | |
import Vuex from 'vuex' | |
import VueI18n from 'vue-i18n' | |
import i18n from '@/i18n' | |
import router from '@/router' | |
// Component | |
import Login from '@/pages/Login' | |
const localVue = createLocalVue() | |
localVue.use(Vuex) | |
localVue.use(VueI18n) | |
describe('Login.vue', () => { | |
let getters | |
let actions | |
let store | |
let wrapper | |
beforeEach(() => { | |
getters = { | |
getLanguage: () => 'zh-TW' | |
} | |
actions = { | |
setLanguage: jest.fn() | |
} | |
store = new Vuex.Store({ | |
state: { | |
loading: false, | |
token: '', | |
lang: 'zh-TW' | |
}, | |
getters, | |
actions | |
}) | |
wrapper = shallow(Login, { i18n, router, store, localVue }) | |
}) | |
it('should render correct contents', () => { | |
const header = wrapper.find('h2.header .content') | |
expect(header.text()).toContain('後台管理系統') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment