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

work_item_weight_spec.js « components « work_items « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 80a1d032ad72c4e3015948a7a45ccde8cd3171ad (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 WorkItemWeight from '~/work_items/components/work_item_weight.vue';

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

  const createComponent = ({ weight, hasIssueWeightsFeature = true } = {}) => {
    wrapper = shallowMount(WorkItemWeight, {
      propsData: {
        weight,
      },
      provide: {
        hasIssueWeightsFeature,
      },
    });
  };

  describe('weight licensed feature', () => {
    describe.each`
      description             | hasIssueWeightsFeature | exists
      ${'when available'}     | ${true}                | ${true}
      ${'when not available'} | ${false}               | ${false}
    `('$description', ({ hasIssueWeightsFeature, exists }) => {
      it(hasIssueWeightsFeature ? 'renders component' : 'does not render component', () => {
        createComponent({ hasIssueWeightsFeature });

        expect(wrapper.find('div').exists()).toBe(exists);
      });
    });
  });

  describe('weight text', () => {
    describe.each`
      description       | weight       | text
      ${'renders 1'}    | ${1}         | ${'1'}
      ${'renders 0'}    | ${0}         | ${'0'}
      ${'renders None'} | ${null}      | ${'None'}
      ${'renders None'} | ${undefined} | ${'None'}
    `('when weight is $weight', ({ description, weight, text }) => {
      it(description, () => {
        createComponent({ weight });

        expect(wrapper.text()).toContain(text);
      });
    });
  });
});