debian-mirror-gitlab/spec/frontend/incidents_settings/components/incidents_settings_tabs_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
import { GlTab } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2020-07-28 23:09:34 +05:30
import IncidentsSettingTabs from '~/incidents_settings/components/incidents_settings_tabs.vue';
describe('IncidentsSettingTabs', () => {
let wrapper;
beforeEach(() => {
2021-01-03 14:25:43 +05:30
wrapper = shallowMount(IncidentsSettingTabs, {
provide: {
service: {},
serviceLevelAgreementSettings: {},
},
});
2020-07-28 23:09:34 +05:30
});
afterEach(() => {
if (wrapper) {
wrapper.destroy();
}
});
2022-10-11 01:57:18 +05:30
const findToggleButton = () => wrapper.findComponent({ ref: 'toggleBtn' });
const findSectionHeader = () => wrapper.findComponent({ ref: 'sectionHeader' });
2020-07-28 23:09:34 +05:30
2022-10-11 01:57:18 +05:30
const findIntegrationTabs = () => wrapper.findAllComponents(GlTab);
2020-07-28 23:09:34 +05:30
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', () => {
2021-03-08 18:12:59 +05:30
const activeTabs = wrapper.vm.$options.tabs.filter((tab) => tab.active);
2020-07-28 23:09:34 +05:30
expect(findIntegrationTabs().length).toBe(activeTabs.length);
activeTabs.forEach((tab, index) => {
2021-03-08 18:12:59 +05:30
expect(findIntegrationTabs().at(index).attributes('title')).toBe(tab.title);
2020-07-28 23:09:34 +05:30
expect(
2021-03-08 18:12:59 +05:30
findIntegrationTabs().at(index).find(`[data-testid="${tab.component}-tab"]`).exists(),
2020-07-28 23:09:34 +05:30
).toBe(true);
});
});
});