1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import { orderBy } from 'lodash';
import { shallowMount } from '@vue/test-utils';
import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue';
import IssueBoardFilteredSpec from '~/boards/components/issue_board_filtered_search.vue';
import issueBoardFilters from 'ee_else_ce/boards/issue_board_filters';
import { mockTokens } from '../mock_data';
jest.mock('ee_else_ce/boards/issue_board_filters');
describe('IssueBoardFilter', () => {
let wrapper;
const findBoardsFilteredSearch = () => wrapper.findComponent(BoardFilteredSearch);
const createComponent = ({ isSignedIn = false } = {}) => {
wrapper = shallowMount(IssueBoardFilteredSpec, {
propsData: {
boardId: 'gid://gitlab/Board/1',
},
provide: {
isSignedIn,
releasesFetchPath: '/releases',
fullPath: 'gitlab-org',
isGroupBoard: true,
},
});
};
let fetchUsersSpy;
let fetchLabelsSpy;
beforeEach(() => {
fetchUsersSpy = jest.fn();
fetchLabelsSpy = jest.fn();
issueBoardFilters.mockReturnValue({
fetchUsers: fetchUsersSpy,
fetchLabels: fetchLabelsSpy,
});
});
afterEach(() => {
wrapper.destroy();
});
describe('default', () => {
beforeEach(() => {
createComponent();
});
it('finds BoardFilteredSearch', () => {
expect(findBoardsFilteredSearch().exists()).toBe(true);
});
it('emits setFilters when setFilters is emitted', () => {
findBoardsFilteredSearch().vm.$emit('setFilters');
expect(wrapper.emitted('setFilters')).toHaveLength(1);
});
it.each`
isSignedIn
${true}
${false}
`(
'passes the correct tokens to BoardFilteredSearch when user sign in is $isSignedIn',
({ isSignedIn }) => {
createComponent({ isSignedIn });
const tokens = mockTokens(
fetchLabelsSpy,
fetchUsersSpy,
wrapper.vm.fetchMilestones,
isSignedIn,
);
expect(findBoardsFilteredSearch().props('tokens')).toEqual(orderBy(tokens, ['title']));
},
);
});
});
|