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

incidents_settings_tabs_spec.js « components « incidents_settings « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff40f1fa008b25ad28ea36066793cded0f2f0b23 (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
import { GlTab } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import IncidentsSettingTabs from '~/incidents_settings/components/incidents_settings_tabs.vue';

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

  beforeEach(() => {
    wrapper = shallowMount(IncidentsSettingTabs, {
      provide: {
        service: {},
        serviceLevelAgreementSettings: {},
      },
    });
  });

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

  const findToggleButton = () => wrapper.find({ ref: 'toggleBtn' });
  const findSectionHeader = () => wrapper.find({ ref: 'sectionHeader' });

  const findIntegrationTabs = () => wrapper.findAll(GlTab);
  it('renders header text', () => {
    expect(findSectionHeader().text()).toBe('Incidents');
  });

  describe('expand/collapse button', () => {
    it('renders as an expand button by default', () => {
      expect(findToggleButton().text()).toBe('Expand');
    });
  });

  it('should render the component', () => {
    expect(wrapper.element).toMatchSnapshot();
  });

  it('should render the tab for each active integration', () => {
    const activeTabs = wrapper.vm.$options.tabs.filter((tab) => tab.active);
    expect(findIntegrationTabs().length).toBe(activeTabs.length);
    activeTabs.forEach((tab, index) => {
      expect(findIntegrationTabs().at(index).attributes('title')).toBe(tab.title);
      expect(
        findIntegrationTabs().at(index).find(`[data-testid="${tab.component}-tab"]`).exists(),
      ).toBe(true);
    });
  });
});