diff options
Diffstat (limited to 'spec/frontend/search/sidebar')
-rw-r--r-- | spec/frontend/search/sidebar/components/app_spec.js | 36 | ||||
-rw-r--r-- | spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js (renamed from spec/frontend/search/sidebar/components/scope_navigation_spec.js) | 6 | ||||
-rw-r--r-- | spec/frontend/search/sidebar/components/scope_sidebar_navigation_spec.js (renamed from spec/frontend/search/sidebar/components/scope_new_navigation_spec.js) | 6 |
3 files changed, 28 insertions, 20 deletions
diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js index e1911534928..ba492833ec4 100644 --- a/spec/frontend/search/sidebar/components/app_spec.js +++ b/spec/frontend/search/sidebar/components/app_spec.js @@ -4,7 +4,8 @@ import Vuex from 'vuex'; import { MOCK_QUERY } from 'jest/search/mock_data'; import GlobalSearchSidebar from '~/search/sidebar/components/app.vue'; import IssuesFilters from '~/search/sidebar/components/issues_filters.vue'; -import ScopeNavigation from '~/search/sidebar/components/scope_navigation.vue'; +import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue'; +import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue'; import LanguageFilter from '~/search/sidebar/components/language_filter/index.vue'; Vue.use(Vuex); @@ -12,22 +13,16 @@ Vue.use(Vuex); describe('GlobalSearchSidebar', () => { let wrapper; - const actionSpies = { - applyQuery: jest.fn(), - resetQuery: jest.fn(), - }; - const getterSpies = { currentScope: jest.fn(() => 'issues'), }; - const createComponent = (initialState, featureFlags) => { + const createComponent = (initialState = {}, featureFlags = {}) => { const store = new Vuex.Store({ state: { urlQuery: MOCK_QUERY, ...initialState, }, - actions: actionSpies, getters: getterSpies, }); @@ -43,13 +38,14 @@ describe('GlobalSearchSidebar', () => { const findSidebarSection = () => wrapper.find('section'); const findFilters = () => wrapper.findComponent(IssuesFilters); - const findSidebarNavigation = () => wrapper.findComponent(ScopeNavigation); + const findScopeLegacyNavigation = () => wrapper.findComponent(ScopeLegacyNavigation); + const findScopeSidebarNavigation = () => wrapper.findComponent(ScopeSidebarNavigation); const findLanguageAggregation = () => wrapper.findComponent(LanguageFilter); describe('renders properly', () => { describe('always', () => { beforeEach(() => { - createComponent({}); + createComponent(); }); it(`shows section`, () => { expect(findSidebarSection().exists()).toBe(true); @@ -77,12 +73,24 @@ describe('GlobalSearchSidebar', () => { }); }); - describe('renders navigation', () => { + describe.each` + currentScope | sidebarNavShown | legacyNavShown + ${'issues'} | ${false} | ${true} + ${''} | ${false} | ${false} + ${'issues'} | ${true} | ${false} + ${''} | ${true} | ${false} + `('renders navigation', ({ currentScope, sidebarNavShown, legacyNavShown }) => { beforeEach(() => { - createComponent({}); + getterSpies.currentScope = jest.fn(() => currentScope); + createComponent({ useSidebarNavigation: sidebarNavShown }); }); - it('shows the vertical navigation', () => { - expect(findSidebarNavigation().exists()).toBe(true); + + it(`${!legacyNavShown ? 'hides' : 'shows'} the legacy navigation`, () => { + expect(findScopeLegacyNavigation().exists()).toBe(legacyNavShown); + }); + + it(`${!sidebarNavShown ? 'hides' : 'shows'} the sidebar navigation`, () => { + expect(findScopeSidebarNavigation().exists()).toBe(sidebarNavShown); }); }); }); diff --git a/spec/frontend/search/sidebar/components/scope_navigation_spec.js b/spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js index e8737384f27..6a94da31a1b 100644 --- a/spec/frontend/search/sidebar/components/scope_navigation_spec.js +++ b/spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js @@ -3,11 +3,11 @@ import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import { MOCK_QUERY, MOCK_NAVIGATION } from 'jest/search/mock_data'; -import ScopeNavigation from '~/search/sidebar/components/scope_navigation.vue'; +import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue'; Vue.use(Vuex); -describe('ScopeNavigation', () => { +describe('ScopeLegacyNavigation', () => { let wrapper; const actionSpies = { @@ -29,7 +29,7 @@ describe('ScopeNavigation', () => { getters: getterSpies, }); - wrapper = shallowMount(ScopeNavigation, { + wrapper = shallowMount(ScopeLegacyNavigation, { store, }); }; diff --git a/spec/frontend/search/sidebar/components/scope_new_navigation_spec.js b/spec/frontend/search/sidebar/components/scope_sidebar_navigation_spec.js index 5207665f883..f31a7c8fa5d 100644 --- a/spec/frontend/search/sidebar/components/scope_new_navigation_spec.js +++ b/spec/frontend/search/sidebar/components/scope_sidebar_navigation_spec.js @@ -1,13 +1,13 @@ import { mount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; -import ScopeNewNavigation from '~/search/sidebar/components/scope_new_navigation.vue'; +import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue'; import NavItem from '~/super_sidebar/components/nav_item.vue'; import { MOCK_QUERY, MOCK_NAVIGATION, MOCK_NAVIGATION_ITEMS } from '../../mock_data'; Vue.use(Vuex); -describe('ScopeNewNavigation', () => { +describe('ScopeSidebarNavigation', () => { let wrapper; const actionSpies = { @@ -30,7 +30,7 @@ describe('ScopeNewNavigation', () => { getters: getterSpies, }); - wrapper = mount(ScopeNewNavigation, { + wrapper = mount(ScopeSidebarNavigation, { store, stubs: { NavItem, |