diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend/reports/components/summary_row_spec.js | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend/reports/components/summary_row_spec.js')
-rw-r--r-- | spec/frontend/reports/components/summary_row_spec.js | 34 |
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); }); }); |