diff options
Diffstat (limited to 'spec/frontend/search/sidebar')
3 files changed, 84 insertions, 82 deletions
diff --git a/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js b/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js index c57eabd57b9..d5ecca4636c 100644 --- a/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js +++ b/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js @@ -1,39 +1,16 @@ import { shallowMount } from '@vue/test-utils'; -import Vue from 'vue'; -import Vuex from 'vuex'; -import { MOCK_QUERY } from 'jest/search/mock_data'; import ConfidentialityFilter from '~/search/sidebar/components/confidentiality_filter.vue'; import RadioFilter from '~/search/sidebar/components/radio_filter.vue'; -Vue.use(Vuex); - describe('ConfidentialityFilter', () => { let wrapper; - const actionSpies = { - applyQuery: jest.fn(), - resetQuery: jest.fn(), - }; - - const createComponent = (initialState) => { - const store = new Vuex.Store({ - state: { - query: MOCK_QUERY, - ...initialState, - }, - actions: actionSpies, - }); - + const createComponent = (initProps) => { wrapper = shallowMount(ConfidentialityFilter, { - store, + ...initProps, }); }; - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - const findRadioFilter = () => wrapper.findComponent(RadioFilter); describe('template', () => { @@ -41,24 +18,28 @@ describe('ConfidentialityFilter', () => { createComponent(); }); - describe.each` - scope | showFilter - ${'issues'} | ${true} - ${'merge_requests'} | ${false} - ${'projects'} | ${false} - ${'milestones'} | ${false} - ${'users'} | ${false} - ${'notes'} | ${false} - ${'wiki_blobs'} | ${false} - ${'blobs'} | ${false} - `(`dropdown`, ({ scope, showFilter }) => { - beforeEach(() => { - createComponent({ query: { scope } }); - }); + it('renders the component', () => { + expect(findRadioFilter().exists()).toBe(true); + }); + }); - it(`does${showFilter ? '' : ' not'} render when scope is ${scope}`, () => { - expect(findRadioFilter().exists()).toBe(showFilter); + describe.each` + hasFeatureFlagEnabled | paddingClass + ${true} | ${'gl-px-5'} + ${false} | ${'gl-px-0'} + `(`RadioFilter`, ({ hasFeatureFlagEnabled, paddingClass }) => { + beforeEach(() => { + createComponent({ + provide: { + glFeatures: { + searchPageVerticalNav: hasFeatureFlagEnabled, + }, + }, }); }); + + it(`has ${paddingClass} class`, () => { + expect(findRadioFilter().classes(paddingClass)).toBe(true); + }); }); }); diff --git a/spec/frontend/search/sidebar/components/filters_spec.js b/spec/frontend/search/sidebar/components/filters_spec.js index 4f217709297..7e564bfa005 100644 --- a/spec/frontend/search/sidebar/components/filters_spec.js +++ b/spec/frontend/search/sidebar/components/filters_spec.js @@ -129,4 +129,44 @@ describe('GlobalSearchSidebarFilters', () => { expect(actionSpies.resetQuery).toHaveBeenCalled(); }); }); + + describe.each` + scope | showFilter + ${'issues'} | ${true} + ${'merge_requests'} | ${false} + ${'projects'} | ${false} + ${'milestones'} | ${false} + ${'users'} | ${false} + ${'notes'} | ${false} + ${'wiki_blobs'} | ${false} + ${'blobs'} | ${false} + `(`ConfidentialityFilter`, ({ scope, showFilter }) => { + beforeEach(() => { + createComponent({ urlQuery: { scope } }); + }); + + it(`does${showFilter ? '' : ' not'} render when scope is ${scope}`, () => { + expect(findConfidentialityFilter().exists()).toBe(showFilter); + }); + }); + + describe.each` + scope | showFilter + ${'issues'} | ${true} + ${'merge_requests'} | ${true} + ${'projects'} | ${false} + ${'milestones'} | ${false} + ${'users'} | ${false} + ${'notes'} | ${false} + ${'wiki_blobs'} | ${false} + ${'blobs'} | ${false} + `(`StatusFilter`, ({ scope, showFilter }) => { + beforeEach(() => { + createComponent({ urlQuery: { scope } }); + }); + + it(`does${showFilter ? '' : ' not'} render when scope is ${scope}`, () => { + expect(findStatusFilter().exists()).toBe(showFilter); + }); + }); }); diff --git a/spec/frontend/search/sidebar/components/status_filter_spec.js b/spec/frontend/search/sidebar/components/status_filter_spec.js index f3152c014b6..2ed199469e6 100644 --- a/spec/frontend/search/sidebar/components/status_filter_spec.js +++ b/spec/frontend/search/sidebar/components/status_filter_spec.js @@ -1,39 +1,16 @@ import { shallowMount } from '@vue/test-utils'; -import Vue from 'vue'; -import Vuex from 'vuex'; -import { MOCK_QUERY } from 'jest/search/mock_data'; import RadioFilter from '~/search/sidebar/components/radio_filter.vue'; import StatusFilter from '~/search/sidebar/components/status_filter.vue'; -Vue.use(Vuex); - describe('StatusFilter', () => { let wrapper; - const actionSpies = { - applyQuery: jest.fn(), - resetQuery: jest.fn(), - }; - - const createComponent = (initialState) => { - const store = new Vuex.Store({ - state: { - query: MOCK_QUERY, - ...initialState, - }, - actions: actionSpies, - }); - + const createComponent = (initProps) => { wrapper = shallowMount(StatusFilter, { - store, + ...initProps, }); }; - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - const findRadioFilter = () => wrapper.findComponent(RadioFilter); describe('template', () => { @@ -41,24 +18,28 @@ describe('StatusFilter', () => { createComponent(); }); - describe.each` - scope | showFilter - ${'issues'} | ${true} - ${'merge_requests'} | ${true} - ${'projects'} | ${false} - ${'milestones'} | ${false} - ${'users'} | ${false} - ${'notes'} | ${false} - ${'wiki_blobs'} | ${false} - ${'blobs'} | ${false} - `(`dropdown`, ({ scope, showFilter }) => { - beforeEach(() => { - createComponent({ query: { scope } }); - }); + it('renders the component', () => { + expect(findRadioFilter().exists()).toBe(true); + }); + }); - it(`does${showFilter ? '' : ' not'} render when scope is ${scope}`, () => { - expect(findRadioFilter().exists()).toBe(showFilter); + describe.each` + hasFeatureFlagEnabled | paddingClass + ${true} | ${'gl-px-5'} + ${false} | ${'gl-px-0'} + `(`RadioFilter`, ({ hasFeatureFlagEnabled, paddingClass }) => { + beforeEach(() => { + createComponent({ + provide: { + glFeatures: { + searchPageVerticalNav: hasFeatureFlagEnabled, + }, + }, }); }); + + it(`has ${paddingClass} class`, () => { + expect(findRadioFilter().classes(paddingClass)).toBe(true); + }); }); }); |