summaryrefslogtreecommitdiff
path: root/spec/frontend/reports/components/summary_row_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/reports/components/summary_row_spec.js')
-rw-r--r--spec/frontend/reports/components/summary_row_spec.js34
1 files changed, 23 insertions, 11 deletions
diff --git a/spec/frontend/reports/components/summary_row_spec.js b/spec/frontend/reports/components/summary_row_spec.js
index 04d9d10dcd2..778660d9e44 100644
--- a/spec/frontend/reports/components/summary_row_spec.js
+++ b/spec/frontend/reports/components/summary_row_spec.js
@@ -1,25 +1,26 @@
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
+import HelpPopover from '~/vue_shared/components/help_popover.vue';
import SummaryRow from '~/reports/components/summary_row.vue';
describe('Summary row', () => {
let wrapper;
- 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',
+ const summary = 'SAST detected 1 new vulnerability and 1 fixed vulnerability';
+ const popoverOptions = {
+ title: 'Static Application Security Testing (SAST)',
+ content: '<a>Learn more about SAST</a>',
};
+ const statusIcon = 'warning';
- const createComponent = ({ propsData = {}, slots = {} } = {}) => {
+ const createComponent = ({ props = {}, slots = {} } = {}) => {
wrapper = extendedWrapper(
mount(SummaryRow, {
propsData: {
+ summary,
+ popoverOptions,
+ statusIcon,
...props,
- ...propsData,
},
slots,
}),
@@ -28,6 +29,7 @@ describe('Summary row', () => {
const findSummary = () => wrapper.findByTestId('summary-row-description');
const findStatusIcon = () => wrapper.findByTestId('summary-row-icon');
+ const findHelpPopover = () => wrapper.findComponent(HelpPopover);
afterEach(() => {
wrapper.destroy();
@@ -36,7 +38,7 @@ describe('Summary row', () => {
it('renders provided summary', () => {
createComponent();
- expect(findSummary().text()).toContain(props.summary);
+ expect(findSummary().text()).toContain(summary);
});
it('renders provided icon', () => {
@@ -44,12 +46,22 @@ describe('Summary row', () => {
expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning');
});
+ it('renders help popover if popoverOptions are provided', () => {
+ createComponent();
+ expect(findHelpPopover().props('options')).toEqual(popoverOptions);
+ });
+
+ it('does not render help popover if popoverOptions are not provided', () => {
+ createComponent({ props: { popoverOptions: null } });
+ expect(findHelpPopover().exists()).toBe(false);
+ });
+
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(wrapper.text()).not.toContain(summary);
expect(findSummary().text()).toContain(summarySlotContent);
});
});