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

associations_list_spec.js « associations « components « users « admin « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d77a645111fd60d2b221514f5fb2d006836117d8 (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
69
70
71
72
73
74
75
76
77
78
import { mountExtended } from 'helpers/vue_test_utils_helper';
import AssociationsList from '~/admin/users/components/associations/associations_list.vue';

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

  const defaultPropsData = {
    associationsCount: {
      groups_count: 1,
      projects_count: 1,
      issues_count: 1,
      merge_requests_count: 1,
    },
  };

  const createComponent = ({ propsData = {} } = {}) => {
    wrapper = mountExtended(AssociationsList, {
      propsData: {
        ...defaultPropsData,
        ...propsData,
      },
    });
  };

  describe('when there is an error', () => {
    it('displays an alert', () => {
      createComponent({
        propsData: {
          associationsCount: new Error(),
        },
      });

      expect(wrapper.html()).toMatchSnapshot();
    });
  });

  describe('when counts are singular', () => {
    it('renders singular counts', () => {
      createComponent();

      expect(wrapper.html()).toMatchSnapshot();
    });
  });

  describe('when counts are plural', () => {
    it('renders plural counts', () => {
      createComponent({
        propsData: {
          associationsCount: {
            groups_count: 2,
            projects_count: 3,
            issues_count: 4,
            merge_requests_count: 5,
          },
        },
      });

      expect(wrapper.html()).toMatchSnapshot();
    });
  });

  describe('when counts are 0', () => {
    it('does not render items', () => {
      createComponent({
        propsData: {
          associationsCount: {
            groups_count: 0,
            projects_count: 0,
            issues_count: 0,
            merge_requests_count: 0,
          },
        },
      });

      expect(wrapper.html()).toMatchSnapshot();
    });
  });
});