summaryrefslogtreecommitdiff
path: root/spec/frontend/sidebar/components/incidents/escalation_status_spec.js
blob: 7a736624fc0ef144638505a2bc1859a8e51bd132 (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
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import EscalationStatus from '~/sidebar/components/incidents/escalation_status.vue';
import {
  STATUS_LABELS,
  STATUS_TRIGGERED,
  STATUS_ACKNOWLEDGED,
} from '~/sidebar/components/incidents/constants';

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

  function createComponent(props) {
    wrapper = mountExtended(EscalationStatus, {
      propsData: {
        value: STATUS_TRIGGERED,
        ...props,
      },
    });
  }

  afterEach(() => {
    wrapper.destroy();
  });

  const findDropdownComponent = () => wrapper.findComponent(GlDropdown);
  const findDropdownItems = () => wrapper.findAllComponents(GlDropdownItem);

  describe('status', () => {
    it('shows the current status', () => {
      createComponent({ value: STATUS_ACKNOWLEDGED });

      expect(findDropdownComponent().props('text')).toBe(STATUS_LABELS[STATUS_ACKNOWLEDGED]);
    });

    it('shows the None option when status is null', () => {
      createComponent({ value: null });

      expect(findDropdownComponent().props('text')).toBe('None');
    });
  });

  describe('events', () => {
    it('selects an item', async () => {
      createComponent();

      await findDropdownItems().at(1).vm.$emit('click');

      expect(wrapper.emitted().input[0][0]).toBe(STATUS_ACKNOWLEDGED);
    });
  });
});