2021-07-14 03:08:27 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import BoardFilteredSearch from '~/boards/components/board_filtered_search.vue';
|
|
|
|
import IssueBoardFilteredSpec from '~/boards/components/issue_board_filtered_search.vue';
|
|
|
|
import issueBoardFilters from '~/boards/issue_board_filters';
|
|
|
|
import { mockTokens } from '../mock_data';
|
|
|
|
|
2021-08-06 06:10:16 +00:00
|
|
|
jest.mock('~/boards/issue_board_filters');
|
|
|
|
|
2021-07-14 03:08:27 +00:00
|
|
|
describe('IssueBoardFilter', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2021-08-06 06:10:16 +00:00
|
|
|
const createComponent = () => {
|
2021-07-14 03:08:27 +00:00
|
|
|
wrapper = shallowMount(IssueBoardFilteredSpec, {
|
|
|
|
props: { fullPath: '', boardType: '' },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('default', () => {
|
2021-08-06 06:10:16 +00:00
|
|
|
let fetchAuthorsSpy;
|
|
|
|
let fetchLabelsSpy;
|
2021-07-14 03:08:27 +00:00
|
|
|
beforeEach(() => {
|
2021-08-06 06:10:16 +00:00
|
|
|
fetchAuthorsSpy = jest.fn();
|
|
|
|
fetchLabelsSpy = jest.fn();
|
|
|
|
|
|
|
|
issueBoardFilters.mockReturnValue({
|
|
|
|
fetchAuthors: fetchAuthorsSpy,
|
|
|
|
fetchLabels: fetchLabelsSpy,
|
|
|
|
});
|
|
|
|
|
2021-07-14 03:08:27 +00:00
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('finds BoardFilteredSearch', () => {
|
|
|
|
expect(wrapper.find(BoardFilteredSearch).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
2021-08-06 06:10:16 +00:00
|
|
|
it('passes the correct tokens to BoardFilteredSearch', () => {
|
|
|
|
const tokens = mockTokens(fetchLabelsSpy, fetchAuthorsSpy, wrapper.vm.fetchMilestones);
|
2021-07-14 03:08:27 +00:00
|
|
|
|
2021-08-06 06:10:16 +00:00
|
|
|
expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(tokens);
|
|
|
|
});
|
2021-07-14 03:08:27 +00:00
|
|
|
});
|
|
|
|
});
|