Test if tab changes after setting was selected

This commit is contained in:
Angelina Filippova 2020-03-21 03:21:05 +03:00
parent 0e972e44e1
commit 044cfbc246
2 changed files with 15 additions and 15 deletions

View file

@ -86,7 +86,7 @@ describe('Form search object', () => {
expect(_.isEqual(formSearchObject(description), expected)).toBeTruthy() expect(_.isEqual(formSearchObject(description), expected)).toBeTruthy()
}) })
it('forms search object for setting without key', () => { it('forms search object for setting without key and description', () => {
const description = [{ const description = [{
group: ":cors_plug", group: ":cors_plug",
label: "Cors plug", label: "Cors plug",

View file

@ -4,10 +4,7 @@ import Element from 'element-ui'
import Settings from '@/views/settings/index' import Settings from '@/views/settings/index'
import flushPromises from 'flush-promises' import flushPromises from 'flush-promises'
import app from '@/store/modules/app' import app from '@/store/modules/app'
import relays from '@/store/modules/relays'
import settings from '@/store/modules/settings' import settings from '@/store/modules/settings'
import user from '@/store/modules/user'
import users from '@/store/modules/users'
import getters from '@/store/getters' import getters from '@/store/getters'
config.mocks["$t"] = () => {} config.mocks["$t"] = () => {}
@ -19,18 +16,13 @@ localVue.use(Element)
describe('Settings search', () => { describe('Settings search', () => {
let store let store
let actions let actions
let permission
beforeEach(() => { beforeEach(() => {
actions = { SetActiveTab: jest.fn() } actions = { ...settings.actions, FetchSettings: jest.fn() }
permission = { addRouters: jest.fn() }
store = new Vuex.Store({ store = new Vuex.Store({
modules: { modules: {
app, app,
permission, settings: { ...settings, actions }
relays,
settings: { ...settings, actions },
user,
}, },
getters getters
}) })
@ -47,17 +39,25 @@ describe('Settings search', () => {
expect(searchInput.exists()).toBe(true) expect(searchInput.exists()).toBe(true)
done() done()
}) })
it('changes tab when search value was selected', async (done) => { it('changes tab when search value was selected', async (done) => {
const wrapper = mount(Settings, { const wrapper = mount(Settings, {
store, store,
localVue localVue
}) })
await flushPromises()
wrapper.vm.handleSearchSelect({ group: 'Pleroma.Upload', key: 'Pleroma.Upload' }) wrapper.vm.handleSearchSelect({ group: 'Pleroma.Upload', key: 'Pleroma.Upload' })
expect(actions.SetActiveTab).toHaveBeenCalled() expect(store.state.settings.activeTab).toBe('upload')
expect(actions.SetActiveTab).toHaveBeenCalledWith(expect.anything(), 'upload', undefined)
wrapper.vm.handleSearchSelect({ group: ':swoosh', key: ':serve_mailbox' })
expect(store.state.settings.activeTab).toBe('mailer')
wrapper.vm.handleSearchSelect({ group: ':pleroma', key: ':admin_token' })
expect(store.state.settings.activeTab).toBe('instance')
wrapper.vm.handleSearchSelect({ group: ':media_proxy', key: ':ssl_options' })
expect(store.state.settings.activeTab).toBe('media-proxy')
wrapper.vm.handleSearchSelect({ group: ':opts', key: ':opts' })
expect(store.state.settings.activeTab).toBe('auto-linker')
done() done()
}) })
}) })