Skip to content

Instantly share code, notes, and snippets.

@SoarLin
Last active March 24, 2018 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SoarLin/ca9dbfeb3128dad873e2f4ebe5dfcc12 to your computer and use it in GitHub Desktop.
Save SoarLin/ca9dbfeb3128dad873e2f4ebe5dfcc12 to your computer and use it in GitHub Desktop.
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