Commit c1deee21 authored by Dave Pisek's avatar Dave Pisek

Specs: Shallow mount where possible

* Adds shallowMount factory
* Uses it in places where possible
parent 704df448
import { createWrapper, mount } from '@vue/test-utils'; import { createWrapper, mount, shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import VulnerabilityActionButtons, { import VulnerabilityActionButtons, {
...@@ -14,13 +14,17 @@ describe('Security Dashboard Action Buttons', () => { ...@@ -14,13 +14,17 @@ describe('Security Dashboard Action Buttons', () => {
let store; let store;
let wrapper; let wrapper;
const createComponent = ({ ...options }) => const wrapperFactory = (mountFn) => ({ ...options }) =>
extendedWrapper( extendedWrapper(
mount(VulnerabilityActionButtons, { mountFn(VulnerabilityActionButtons, {
...options, ...options,
store, store,
}), }),
); );
const createShallowComponent = wrapperFactory(shallowMount);
const createFullComponent = wrapperFactory(mount);
const findAllButtons = () => wrapper.findAllComponents(GlButton); const findAllButtons = () => wrapper.findAllComponents(GlButton);
const findMoreInfoButton = () => wrapper.findByTestId('more-info'); const findMoreInfoButton = () => wrapper.findByTestId('more-info');
const findCreateIssueButton = () => wrapper.findByTestId('create-issue'); const findCreateIssueButton = () => wrapper.findByTestId('create-issue');
...@@ -38,7 +42,7 @@ describe('Security Dashboard Action Buttons', () => { ...@@ -38,7 +42,7 @@ describe('Security Dashboard Action Buttons', () => {
describe('with a fresh vulnerability', () => { describe('with a fresh vulnerability', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createFullComponent({
propsData: { propsData: {
vulnerability: mockDataVulnerabilities[0], vulnerability: mockDataVulnerabilities[0],
canCreateIssue: true, canCreateIssue: true,
...@@ -90,7 +94,7 @@ describe('Security Dashboard Action Buttons', () => { ...@@ -90,7 +94,7 @@ describe('Security Dashboard Action Buttons', () => {
describe('with Jira issues for vulnerabilities enabled', () => { describe('with Jira issues for vulnerabilities enabled', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createFullComponent({
propsData: { propsData: {
vulnerability: mockDataVulnerabilities[8], vulnerability: mockDataVulnerabilities[8],
canCreateIssue: true, canCreateIssue: true,
...@@ -140,7 +144,7 @@ describe('Security Dashboard Action Buttons', () => { ...@@ -140,7 +144,7 @@ describe('Security Dashboard Action Buttons', () => {
describe('with a vulnerability that has an issue', () => { describe('with a vulnerability that has an issue', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createShallowComponent({
propsData: { propsData: {
vulnerability: mockDataVulnerabilities[3], vulnerability: mockDataVulnerabilities[3],
}, },
...@@ -158,7 +162,7 @@ describe('Security Dashboard Action Buttons', () => { ...@@ -158,7 +162,7 @@ describe('Security Dashboard Action Buttons', () => {
describe('with a vulnerability that has been dismissed', () => { describe('with a vulnerability that has been dismissed', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createShallowComponent({
propsData: { propsData: {
vulnerability: mockDataVulnerabilities[2], vulnerability: mockDataVulnerabilities[2],
canDismissVulnerability: true, canDismissVulnerability: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment