refs #209 Add integration tests for Jump modal

This commit is contained in:
AkiraFukushima 2019-02-16 18:54:02 +09:00
parent 859a0e1ab3
commit a9b82b331b
1 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,101 @@
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import i18n from '~/src/config/i18n'
import router from '@/router'
import Jump from '~/src/renderer/store/TimelineSpace/Modals/Jump'
const state = {
modalOpen: true,
channel: '',
defaultChannelList: [
{
name: i18n.t('side_menu.home'),
path: 'home'
},
{
name: i18n.t('side_menu.notification'),
path: 'notifications'
},
{
name: i18n.t('side_menu.favourite'),
path: 'favourites'
},
{
name: i18n.t('side_menu.local'),
path: 'local'
},
{
name: i18n.t('side_menu.public'),
path: 'public'
},
{
name: i18n.t('side_menu.hashtag'),
path: 'hashtag'
},
{
name: i18n.t('side_menu.search'),
path: 'search'
},
{
name: i18n.t('side_menu.direct'),
path: 'direct-messages'
}
],
listChannelList: [],
tagChannelList: [],
selectedChannel: {
name: i18n.t('side_menu.home'),
path: 'home'
}
}
const initState = {
namespaced: true,
state: state,
actions: Jump.actions,
mutations: Jump.mutations
}
const timelineState = {
namespaced: true,
state: {
account: {
_id: '0'
}
}
}
describe('Jump', () => {
let store
let localVue
beforeEach(() => {
localVue = createLocalVue()
localVue.use(Vuex)
store = new Vuex.Store({
modules: {
Jump: initState,
TimelineSpace: timelineState
}
})
})
describe('jumpCurrentSelected', () => {
it('should be changed', () => {
store.dispatch('Jump/jumpCurrentSelected')
expect(store.state.Jump.modalOpen).toEqual(false)
expect(router.push).toHaveBeenCalledWith({ path: '/0/home' })
})
})
describe('jump', () => {
it('should be changed', () => {
store.dispatch('Jump/jump', {
name: 'public',
path: 'public'
})
expect(store.state.Jump.modalOpen).toEqual(false)
expect(router.push).toHaveBeenCalledWith({ path: '/0/public' })
})
})
})