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

timeline_events_list_item_spec.js « incidents « components « show « issues « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7e51219ffa7776b9d9de7a06ebe6202d05c28c8a (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
79
80
81
82
83
84
85
86
87
import timezoneMock from 'timezone-mock';
import merge from 'lodash/merge';
import { GlIcon } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import IncidentTimelineEventListItem from '~/issues/show/components/incidents/timeline_events_list_item.vue';
import { mockEvents } from './mock_data';

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

  const mountComponent = (propsData) => {
    const { action, noteHtml, occurredAt } = mockEvents[0];
    wrapper = mountExtended(
      IncidentTimelineEventListItem,
      merge({
        propsData: {
          action,
          noteHtml,
          occurredAt,
          isLastItem: false,
          ...propsData,
        },
      }),
    );
  };

  const findCommentIcon = () => wrapper.findComponent(GlIcon);
  const findTextContainer = () => wrapper.findByTestId('event-text-container');
  const findEventTime = () => wrapper.findByTestId('event-time');

  describe('template', () => {
    it('shows comment icon', () => {
      mountComponent();

      expect(findCommentIcon().exists()).toBe(true);
    });

    it('sets correct props for icon', () => {
      mountComponent();

      expect(findCommentIcon().props('name')).toBe(mockEvents[0].action);
    });

    it('displays the correct time', () => {
      mountComponent();

      expect(findEventTime().text()).toBe('15:59 UTC');
    });

    describe('last item in list', () => {
      it('shows a bottom border when not the last item', () => {
        mountComponent();

        expect(findTextContainer().classes()).toContain('gl-border-1');
      });

      it('does not show a bottom border when the last item', () => {
        mountComponent({ isLastItem: true });

        expect(wrapper.classes()).not.toContain('gl-border-1');
      });
    });

    describe.each`
      timezone
      ${'Europe/London'}
      ${'US/Pacific'}
      ${'Australia/Adelaide'}
    `('when viewing in timezone', ({ timezone }) => {
      describe(timezone, () => {
        beforeEach(() => {
          timezoneMock.register(timezone);

          mountComponent();
        });

        afterEach(() => {
          timezoneMock.unregister();
        });

        it('displays the correct time', () => {
          expect(findEventTime().text()).toBe('15:59 UTC');
        });
      });
    });
  });
});