debian-mirror-gitlab/spec/frontend/reports/components/summary_row_spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
import { mount } from '@vue/test-utils';
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 = {} } = {}) => {
wrapper = mount(SummaryRow, {
propsData: {
...props,
...propsData,
},
slots,
});
};
const findSummary = () => wrapper.find('.report-block-list-issue-description-text');
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();
expect(findSummary().text()).toEqual(props.summary);
2018-11-18 11:00:15 +05:30
});
it('renders provided icon', () => {
2020-07-28 23:09:34 +05:30
createComponent();
expect(wrapper.find('.report-block-list-icon span').classes()).toContain(
2018-11-18 11:00:15 +05:30
'js-ci-status-icon-warning',
);
});
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);
expect(findSummary().text()).toEqual(summarySlotContent);
});
});
2018-11-18 11:00:15 +05:30
});