2020-07-13 09:09:29 +00:00
|
|
|
import { GlTab } from '@gitlab/ui';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-07-13 09:09:29 +00:00
|
|
|
import IncidentsSettingTabs from '~/incidents_settings/components/incidents_settings_tabs.vue';
|
|
|
|
|
|
|
|
describe('IncidentsSettingTabs', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-10-13 06:09:09 +00:00
|
|
|
wrapper = shallowMount(IncidentsSettingTabs, {
|
|
|
|
provide: {
|
|
|
|
service: {},
|
|
|
|
serviceLevelAgreementSettings: {},
|
|
|
|
},
|
|
|
|
});
|
2020-07-13 09:09:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-12 21:10:38 +00:00
|
|
|
const findToggleButton = () => wrapper.findComponent({ ref: 'toggleBtn' });
|
|
|
|
const findSectionHeader = () => wrapper.findComponent({ ref: 'sectionHeader' });
|
2020-07-13 09:09:29 +00:00
|
|
|
|
|
|
|
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', () => {
|
2020-12-23 21:10:24 +00:00
|
|
|
const activeTabs = wrapper.vm.$options.tabs.filter((tab) => tab.active);
|
2020-07-13 09:09:29 +00:00
|
|
|
expect(findIntegrationTabs().length).toBe(activeTabs.length);
|
|
|
|
activeTabs.forEach((tab, index) => {
|
2020-12-23 12:10:26 +00:00
|
|
|
expect(findIntegrationTabs().at(index).attributes('title')).toBe(tab.title);
|
2020-07-13 09:09:29 +00:00
|
|
|
expect(
|
2020-12-23 12:10:26 +00:00
|
|
|
findIntegrationTabs().at(index).find(`[data-testid="${tab.component}-tab"]`).exists(),
|
2020-07-13 09:09:29 +00:00
|
|
|
).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|