Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_board_filtered_search_spec.js « components « boards « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b6de46f8db89a08149e383e4d3007ea8308e3a2e (plain)
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
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';

jest.mock('~/boards/issue_board_filters');

describe('IssueBoardFilter', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = shallowMount(IssueBoardFilteredSpec, {
      props: { fullPath: '', boardType: '' },
    });
  };

  afterEach(() => {
    wrapper.destroy();
  });

  describe('default', () => {
    let fetchAuthorsSpy;
    let fetchLabelsSpy;
    beforeEach(() => {
      fetchAuthorsSpy = jest.fn();
      fetchLabelsSpy = jest.fn();

      issueBoardFilters.mockReturnValue({
        fetchAuthors: fetchAuthorsSpy,
        fetchLabels: fetchLabelsSpy,
      });

      createComponent();
    });

    it('finds BoardFilteredSearch', () => {
      expect(wrapper.find(BoardFilteredSearch).exists()).toBe(true);
    });

    it('passes the correct tokens to BoardFilteredSearch', () => {
      const tokens = mockTokens(fetchLabelsSpy, fetchAuthorsSpy, wrapper.vm.fetchMilestones);

      expect(wrapper.find(BoardFilteredSearch).props('tokens')).toEqual(tokens);
    });
  });
});