2020-07-16 11:09:38 -04:00
|
|
|
import { mount } from '@vue/test-utils';
|
2021-03-02 13:11:20 -05:00
|
|
|
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
|
2020-07-16 11:09:38 -04:00
|
|
|
import SummaryRow from '~/reports/components/summary_row.vue';
|
2018-07-13 10:52:08 -04:00
|
|
|
|
|
|
|
describe('Summary row', () => {
|
2020-07-16 11:09:38 -04:00
|
|
|
let wrapper;
|
2018-07-13 10:52:08 -04:00
|
|
|
|
|
|
|
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-16 11:09:38 -04:00
|
|
|
const createComponent = ({ propsData = {}, slots = {} } = {}) => {
|
2021-03-02 13:11:20 -05:00
|
|
|
wrapper = extendedWrapper(
|
|
|
|
mount(SummaryRow, {
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
...propsData,
|
|
|
|
},
|
|
|
|
slots,
|
|
|
|
}),
|
|
|
|
);
|
2020-07-16 11:09:38 -04:00
|
|
|
};
|
|
|
|
|
2021-03-02 13:11:20 -05:00
|
|
|
const findSummary = () => wrapper.findByTestId('summary-row-description');
|
|
|
|
const findStatusIcon = () => wrapper.findByTestId('summary-row-icon');
|
2018-07-13 10:52:08 -04:00
|
|
|
|
|
|
|
afterEach(() => {
|
2020-07-16 11:09:38 -04:00
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-07-13 10:52:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided summary', () => {
|
2020-07-16 11:09:38 -04:00
|
|
|
createComponent();
|
2021-01-28 16:09:04 -05:00
|
|
|
expect(findSummary().text()).toContain(props.summary);
|
2018-07-13 10:52:08 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided icon', () => {
|
2020-07-16 11:09:38 -04:00
|
|
|
createComponent();
|
2021-03-02 13:11:20 -05:00
|
|
|
expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning');
|
2018-07-13 10:52:08 -04:00
|
|
|
});
|
2020-07-16 11:09:38 -04:00
|
|
|
|
|
|
|
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-01-28 16:09:04 -05:00
|
|
|
expect(findSummary().text()).toContain(summarySlotContent);
|
2020-07-16 11:09:38 -04:00
|
|
|
});
|
|
|
|
});
|
2018-07-13 10:52:08 -04:00
|
|
|
});
|