2022-01-21 18:12:45 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
2021-02-14 18:09:20 +00:00
|
|
|
import Vuex from 'vuex';
|
2020-11-06 06:08:51 +00:00
|
|
|
import { MOCK_QUERY } from 'jest/search/mock_data';
|
|
|
|
import RadioFilter from '~/search/sidebar/components/radio_filter.vue';
|
2021-02-14 18:09:20 +00:00
|
|
|
import StatusFilter from '~/search/sidebar/components/status_filter.vue';
|
2020-11-06 06:08:51 +00:00
|
|
|
|
2022-01-21 18:12:45 +00:00
|
|
|
Vue.use(Vuex);
|
2020-11-06 06:08:51 +00:00
|
|
|
|
|
|
|
describe('StatusFilter', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const actionSpies = {
|
|
|
|
applyQuery: jest.fn(),
|
|
|
|
resetQuery: jest.fn(),
|
|
|
|
};
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
const createComponent = (initialState) => {
|
2020-11-06 06:08:51 +00:00
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
|
|
|
query: MOCK_QUERY,
|
|
|
|
...initialState,
|
|
|
|
},
|
|
|
|
actions: actionSpies,
|
|
|
|
});
|
|
|
|
|
|
|
|
wrapper = shallowMount(StatusFilter, {
|
|
|
|
store,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
const findRadioFilter = () => wrapper.find(RadioFilter);
|
|
|
|
|
|
|
|
describe('template', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
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(`does${showFilter ? '' : ' not'} render when scope is ${scope}`, () => {
|
|
|
|
expect(findRadioFilter().exists()).toBe(showFilter);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|