Check if tabs is changed when search value was selected

This commit is contained in:
Angelina Filippova 2020-03-19 23:06:23 +03:00
parent 0cbebe2832
commit f4df449f1a
2 changed files with 30 additions and 20 deletions

View file

@ -2,9 +2,13 @@ import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import Element from 'element-ui'
import Settings from '@/views/settings/index'
import storeConfig from './store.conf'
import { cloneDeep } from 'lodash'
import flushPromises from 'flush-promises'
import app from '@/store/modules/app'
import getters from '@/store/getters'
import relays from '@/store/modules/relays'
import settings from '@/store/modules/settings'
import user from '@/store/modules/user'
import users from '@/store/modules/users'
config.mocks["$t"] = () => {}
@ -14,9 +18,21 @@ localVue.use(Element)
describe('Settings search', () => {
let store
let actions
beforeEach(() => {
store = new Vuex.Store(cloneDeep(storeConfig))
actions = { SetActiveTab: jest.fn() }
store = new Vuex.Store({
modules: {
app,
relays,
settings: { ...settings, actions },
user,
users
},
getters
})
})
it('shows search input', async (done) => {
@ -30,4 +46,15 @@ describe('Settings search', () => {
expect(searchInput.exists()).toBe(true)
done()
})
it('changes tab when search value was selected', async (done) => {
const wrapper = mount(Settings, {
store,
localVue
})
await flushPromises()
wrapper.vm.handleSearchSelect({ group: 'Pleroma.Upload', key: 'Pleroma.Upload' })
expect(actions.SetActiveTab).toHaveBeenCalled()
done()
})
})

View file

@ -1,17 +0,0 @@
import app from '@/store/modules/app'
import user from '@/store/modules/user'
import users from '@/store/modules/users'
import relays from '@/store/modules/relays'
import settings from '@/store/modules/settings'
import getters from '@/store/getters'
export default {
modules: {
app,
relays,
settings,
user,
users
},
getters
}