summaryrefslogtreecommitdiff
path: root/spec/frontend/issues/list/components/empty_state_with_any_issues_spec.js
blob: d0d20ef03e1f7dff5b1ff0ff3e72875c62fed543 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import EmptyStateWithAnyIssues from '~/issues/list/components/empty_state_with_any_issues.vue';
import IssuesListApp from '~/issues/list/components/issues_list_app.vue';

describe('EmptyStateWithAnyIssues component', () => {
  let wrapper;

  const defaultProvide = {
    emptyStateSvgPath: 'empty/state/svg/path',
    newIssuePath: 'new/issue/path',
    showNewIssueLink: false,
  };

  const findGlEmptyState = () => wrapper.findComponent(GlEmptyState);

  const mountComponent = (props = {}) => {
    wrapper = shallowMount(EmptyStateWithAnyIssues, {
      propsData: {
        hasSearch: true,
        isOpenTab: true,
        ...props,
      },
      provide: defaultProvide,
    });
  };

  describe('when there is a search (with no results)', () => {
    beforeEach(() => {
      mountComponent({ hasSearch: true });
    });

    it('shows empty state', () => {
      expect(findGlEmptyState().props()).toMatchObject({
        description: IssuesListApp.i18n.noSearchResultsDescription,
        title: IssuesListApp.i18n.noSearchResultsTitle,
        svgPath: defaultProvide.emptyStateSvgPath,
      });
    });
  });

  describe('when "Open" tab is active', () => {
    beforeEach(() => {
      mountComponent({ hasSearch: false, isOpenTab: true });
    });

    it('shows empty state', () => {
      expect(findGlEmptyState().props()).toMatchObject({
        description: IssuesListApp.i18n.noOpenIssuesDescription,
        title: IssuesListApp.i18n.noOpenIssuesTitle,
        svgPath: defaultProvide.emptyStateSvgPath,
      });
    });
  });

  describe('when "Closed" tab is active', () => {
    beforeEach(() => {
      mountComponent({ hasSearch: false, isOpenTab: false });
    });

    it('shows empty state', () => {
      expect(findGlEmptyState().props()).toMatchObject({
        title: IssuesListApp.i18n.noClosedIssuesTitle,
        svgPath: defaultProvide.emptyStateSvgPath,
      });
    });
  });
});