2020-07-28 23:09:34 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
2021-04-17 20:07:23 +05:30
|
|
|
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
|
2020-07-28 23:09:34 +05:30
|
|
|
import SummaryRow from '~/reports/components/summary_row.vue';
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
describe('Summary row', () => {
|
2020-07-28 23:09:34 +05:30
|
|
|
let wrapper;
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
const props = {
|
|
|
|
summary: 'SAST detected 1 new vulnerability and 1 fixed vulnerability',
|
|
|
|
popoverOptions: {
|
|
|
|
title: 'Static Application Security Testing (SAST)',
|
|
|
|
content: '<a>Learn more about SAST</a>',
|
|
|
|
},
|
|
|
|
statusIcon: 'warning',
|
|
|
|
};
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const createComponent = ({ propsData = {}, slots = {} } = {}) => {
|
2021-04-17 20:07:23 +05:30
|
|
|
wrapper = extendedWrapper(
|
|
|
|
mount(SummaryRow, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
...propsData,
|
|
|
|
},
|
|
|
|
slots,
|
|
|
|
}),
|
|
|
|
);
|
2020-07-28 23:09:34 +05:30
|
|
|
};
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const findSummary = () => wrapper.findByTestId('summary-row-description');
|
|
|
|
const findStatusIcon = () => wrapper.findByTestId('summary-row-icon');
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
afterEach(() => {
|
2020-07-28 23:09:34 +05:30
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided summary', () => {
|
2020-07-28 23:09:34 +05:30
|
|
|
createComponent();
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(findSummary().text()).toContain(props.summary);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided icon', () => {
|
2020-07-28 23:09:34 +05:30
|
|
|
createComponent();
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning');
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe('summary slot', () => {
|
|
|
|
it('replaces the summary prop', () => {
|
|
|
|
const summarySlotContent = 'Summary slot content';
|
|
|
|
createComponent({ slots: { summary: summarySlotContent } });
|
|
|
|
|
|
|
|
expect(wrapper.text()).not.toContain(props.summary);
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(findSummary().text()).toContain(summarySlotContent);
|
2020-07-28 23:09:34 +05:30
|
|
|
});
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|