From 11890956751318893027f38e1a1e3fc052e442e1 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 7 Feb 2021 02:39:36 +0300 Subject: [PATCH] Fix tests for settings search --- test/views/settings/index.test.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/views/settings/index.test.js b/test/views/settings/index.test.js index 961a739d..35ec4405 100644 --- a/test/views/settings/index.test.js +++ b/test/views/settings/index.test.js @@ -7,6 +7,7 @@ import app from '@/store/modules/app' import settings from '@/store/modules/settings' import user from '@/store/modules/user' import getters from '@/store/getters' +import _ from 'lodash' config.mocks["$t"] = () => {} @@ -22,6 +23,8 @@ describe('Settings search', () => { let store let actions let appActions + let $route + let $router beforeEach(() => { appActions = { ...app.actions, NeedReboot: jest.fn() } @@ -34,11 +37,17 @@ describe('Settings search', () => { }, getters }) + $route = { path: '/settings/path' } + $router = [] }) it('shows search input', async (done) => { const wrapper = mount(Settings, { store, + mocks: { + $route, + $router + }, localVue }) @@ -50,19 +59,27 @@ describe('Settings search', () => { it('changes tab when search value was selected', async (done) => { const wrapper = mount(Settings, { store, + mocks: { + $route, + $router + }, localVue }) wrapper.vm.handleSearchSelect({ group: 'Pleroma.Upload', key: 'Pleroma.Upload' }) - expect(store.state.settings.activeTab).toBe('upload') + expect(store.state.settings.searchQuery).toBe('Pleroma.Upload') + expect(_.isEqual($router[0], { path: `/settings/upload` })).toBeTruthy() wrapper.vm.handleSearchSelect({ group: ':swoosh', key: ':serve_mailbox' }) - expect(store.state.settings.activeTab).toBe('mailer') + expect(store.state.settings.searchQuery).toBe(':serve_mailbox') + expect(_.isEqual($router[1], { path: `/settings/mailer` })).toBeTruthy() wrapper.vm.handleSearchSelect({ group: ':pleroma', key: ':admin_token' }) - expect(store.state.settings.activeTab).toBe('instance') + expect(store.state.settings.searchQuery).toBe(':admin_token') + expect(_.isEqual($router[2], { path: `/settings/instance` })).toBeTruthy() wrapper.vm.handleSearchSelect({ group: ':media_proxy', key: ':ssl_options' }) - expect(store.state.settings.activeTab).toBe('media-proxy') + expect(store.state.settings.searchQuery).toBe(':ssl_options') + expect(_.isEqual($router[3], { path: `/settings/media-proxy` })).toBeTruthy() done() })