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

contribution_event_reopened_spec.js « contribution_event « components « contribution_events « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 87f3080a98fd3a323c3f3540de302791fa9038ba (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
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ContributionEventReopened from '~/contribution_events/components/contribution_event/contribution_event_reopened.vue';
import ContributionEventBase from '~/contribution_events/components/contribution_event/contribution_event_base.vue';
import { TARGET_TYPE_WORK_ITEM } from '~/contribution_events/constants';
import {
  eventMilestoneReopened,
  eventIssueReopened,
  eventMergeRequestReopened,
  eventTaskReopened,
  eventIncidentReopened,
} from '../../utils';

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

  const createComponent = ({ propsData }) => {
    wrapper = shallowMountExtended(ContributionEventReopened, {
      propsData,
    });
  };

  describe.each`
    event                                       | expectedMessage                                                     | iconName
    ${eventMilestoneReopened()}                 | ${'Reopened milestone %{targetLink} in %{resourceParentLink}.'}     | ${'status_open'}
    ${eventIssueReopened()}                     | ${'Reopened issue %{targetLink} in %{resourceParentLink}.'}         | ${'status_open'}
    ${eventMergeRequestReopened()}              | ${'Reopened merge request %{targetLink} in %{resourceParentLink}.'} | ${'merge-request-open'}
    ${{ target: { type: 'unsupported type' } }} | ${'Reopened resource.'}                                             | ${'status_open'}
  `('when event target type is $event.target.type', ({ event, expectedMessage, iconName }) => {
    it('renders `ContributionEventBase` with correct props', () => {
      createComponent({ propsData: { event } });

      expect(wrapper.findComponent(ContributionEventBase).props()).toMatchObject({
        event,
        message: expectedMessage,
        iconName,
        iconClass: 'gl-text-green-500',
      });
    });
  });

  describe(`when event target type is ${TARGET_TYPE_WORK_ITEM}`, () => {
    describe.each`
      event                                                                          | expectedMessage
      ${eventTaskReopened()}                                                         | ${'Reopened task %{targetLink} in %{resourceParentLink}.'}
      ${eventIncidentReopened()}                                                     | ${'Reopened incident %{targetLink} in %{resourceParentLink}.'}
      ${{ target: { type: TARGET_TYPE_WORK_ITEM, issue_type: 'unsupported type' } }} | ${'Reopened resource.'}
    `('when issue type is $event.target.issue_type', ({ event, expectedMessage }) => {
      it('renders `ContributionEventBase` with correct props', () => {
        createComponent({ propsData: { event } });

        expect(wrapper.findComponent(ContributionEventBase).props()).toMatchObject({
          event,
          message: expectedMessage,
          iconName: 'status_open',
          iconClass: 'gl-text-green-500',
        });
      });
    });
  });
});