2020-03-16 19:47:08 +00:00
|
|
|
import Vuex from 'vuex'
|
|
|
|
import { mount, createLocalVue, config } from '@vue/test-utils'
|
|
|
|
import Element from 'element-ui'
|
|
|
|
import Settings from '@/views/settings/index'
|
|
|
|
import flushPromises from 'flush-promises'
|
2020-03-19 20:06:23 +00:00
|
|
|
import app from '@/store/modules/app'
|
|
|
|
import settings from '@/store/modules/settings'
|
2020-03-19 22:06:22 +00:00
|
|
|
import getters from '@/store/getters'
|
2020-03-16 19:47:08 +00:00
|
|
|
|
|
|
|
config.mocks["$t"] = () => {}
|
|
|
|
|
|
|
|
const localVue = createLocalVue()
|
|
|
|
localVue.use(Vuex)
|
|
|
|
localVue.use(Element)
|
|
|
|
|
|
|
|
describe('Settings search', () => {
|
|
|
|
let store
|
2020-03-19 20:06:23 +00:00
|
|
|
let actions
|
2020-04-17 22:27:00 +00:00
|
|
|
let appActions
|
2020-03-16 19:47:08 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-04-17 22:27:00 +00:00
|
|
|
appActions = { ...app.actions, NeedReboot: jest.fn() }
|
|
|
|
actions = { ...settings.actions, FetchSettings: jest.fn(), GetNodeInfo: jest.fn() }
|
2020-03-19 20:06:23 +00:00
|
|
|
store = new Vuex.Store({
|
|
|
|
modules: {
|
2020-04-17 22:27:00 +00:00
|
|
|
app: { ...app, actions: appActions },
|
2020-03-21 00:21:05 +00:00
|
|
|
settings: { ...settings, actions }
|
2020-03-19 20:06:23 +00:00
|
|
|
},
|
|
|
|
getters
|
|
|
|
})
|
2020-03-16 19:47:08 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('shows search input', async (done) => {
|
|
|
|
const wrapper = mount(Settings, {
|
|
|
|
store,
|
|
|
|
localVue
|
|
|
|
})
|
|
|
|
|
|
|
|
await flushPromises()
|
|
|
|
const searchInput = wrapper.find('.settings-search-input')
|
|
|
|
expect(searchInput.exists()).toBe(true)
|
|
|
|
done()
|
|
|
|
})
|
2020-03-19 20:06:23 +00:00
|
|
|
it('changes tab when search value was selected', async (done) => {
|
|
|
|
const wrapper = mount(Settings, {
|
|
|
|
store,
|
|
|
|
localVue
|
|
|
|
})
|
|
|
|
wrapper.vm.handleSearchSelect({ group: 'Pleroma.Upload', key: 'Pleroma.Upload' })
|
2020-03-21 00:21:05 +00:00
|
|
|
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')
|
2020-03-19 22:06:22 +00:00
|
|
|
|
2020-03-19 20:06:23 +00:00
|
|
|
done()
|
|
|
|
})
|
2020-03-16 19:47:08 +00:00
|
|
|
})
|