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()
})
it('forms search object for setting without key', () => {
it('forms search object for setting without key and description', () => {
const description = [{
group: ":cors_plug",
label: "Cors plug",

View file

@ -4,10 +4,7 @@ import Element from 'element-ui'
import Settings from '@/views/settings/index'
import flushPromises from 'flush-promises'
import app from '@/store/modules/app'
import relays from '@/store/modules/relays'
import settings from '@/store/modules/settings'
import user from '@/store/modules/user'
import users from '@/store/modules/users'
import getters from '@/store/getters'
config.mocks["$t"] = () => {}
@ -19,18 +16,13 @@ localVue.use(Element)
describe('Settings search', () => {
let store
let actions
let permission
beforeEach(() => {
actions = { SetActiveTab: jest.fn() }
permission = { addRouters: jest.fn() }
actions = { ...settings.actions, FetchSettings: jest.fn() }
store = new Vuex.Store({
modules: {
app,
permission,
relays,
settings: { ...settings, actions },
user,
settings: { ...settings, actions }
},
getters
})
@ -47,17 +39,25 @@ 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()
expect(actions.SetActiveTab).toHaveBeenCalledWith(expect.anything(), 'upload', undefined)
expect(store.state.settings.activeTab).toBe('upload')
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()
})
})