From c1deee2151fbbe8635f50c45bf294d31b6974776 Mon Sep 17 00:00:00 2001 From: Dave Pisek <dpisek@gitlab.com> Date: Mon, 1 Feb 2021 16:51:29 +1100 Subject: [PATCH] Specs: Shallow mount where possible * Adds shallowMount factory * Uses it in places where possible --- .../vulnerability_action_buttons_spec.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js b/ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js index 57b9ce2f2eb..c1771f9e12d 100644 --- a/ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js +++ b/ee/spec/frontend/security_dashboard/components/vulnerability_action_buttons_spec.js @@ -1,4 +1,4 @@ -import { createWrapper, mount } from '@vue/test-utils'; +import { createWrapper, mount, shallowMount } from '@vue/test-utils'; import { GlButton } from '@gitlab/ui'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import VulnerabilityActionButtons, { @@ -14,13 +14,17 @@ describe('Security Dashboard Action Buttons', () => { let store; let wrapper; - const createComponent = ({ ...options }) => + const wrapperFactory = (mountFn) => ({ ...options }) => extendedWrapper( - mount(VulnerabilityActionButtons, { + mountFn(VulnerabilityActionButtons, { ...options, store, }), ); + + const createShallowComponent = wrapperFactory(shallowMount); + const createFullComponent = wrapperFactory(mount); + const findAllButtons = () => wrapper.findAllComponents(GlButton); const findMoreInfoButton = () => wrapper.findByTestId('more-info'); const findCreateIssueButton = () => wrapper.findByTestId('create-issue'); @@ -38,7 +42,7 @@ describe('Security Dashboard Action Buttons', () => { describe('with a fresh vulnerability', () => { beforeEach(() => { - wrapper = createComponent({ + wrapper = createFullComponent({ propsData: { vulnerability: mockDataVulnerabilities[0], canCreateIssue: true, @@ -90,7 +94,7 @@ describe('Security Dashboard Action Buttons', () => { describe('with Jira issues for vulnerabilities enabled', () => { beforeEach(() => { - wrapper = createComponent({ + wrapper = createFullComponent({ propsData: { vulnerability: mockDataVulnerabilities[8], canCreateIssue: true, @@ -140,7 +144,7 @@ describe('Security Dashboard Action Buttons', () => { describe('with a vulnerability that has an issue', () => { beforeEach(() => { - wrapper = createComponent({ + wrapper = createShallowComponent({ propsData: { vulnerability: mockDataVulnerabilities[3], }, @@ -158,7 +162,7 @@ describe('Security Dashboard Action Buttons', () => { describe('with a vulnerability that has been dismissed', () => { beforeEach(() => { - wrapper = createComponent({ + wrapper = createShallowComponent({ propsData: { vulnerability: mockDataVulnerabilities[2], canDismissVulnerability: true, -- 2.30.9