Commit 21fbfe27 authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Fatih Acet

Move security reports tests to Jest

- Add missing bootstrap import in security reports store actions
- Adjust path to test_constants
- Replace spyOnDependency() with jest.mock() in security reports
parent 05513ff5
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/dast_issue_body.vue'; import component from 'ee/vue_shared/security_reports/components/dast_issue_body.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
describe('dast issue body', () => { describe('dast issue body', () => {
let vm; let vm;
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/event_item.vue'; import component from 'ee/vue_shared/security_reports/components/event_item.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
describe('Event Item', () => { describe('Event Item', () => {
const Component = Vue.extend(component); const Component = Vue.extend(component);
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/modal.vue'; import component from 'ee/vue_shared/security_reports/components/modal.vue';
import createState from 'ee/vue_shared/security_reports/store/state'; import createState from 'ee/vue_shared/security_reports/store/state';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
describe('Security Reports modal', () => { describe('Security Reports modal', () => {
const Component = Vue.extend(component); const Component = Vue.extend(component);
...@@ -36,7 +36,7 @@ describe('Security Reports modal', () => { ...@@ -36,7 +36,7 @@ describe('Security Reports modal', () => {
}); });
it('emits revertDismissIssue when undo dismiss button is clicked', () => { it('emits revertDismissIssue when undo dismiss button is clicked', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit');
const button = vm.$el.querySelector('.js-dismiss-btn'); const button = vm.$el.querySelector('.js-dismiss-btn');
button.click(); button.click();
...@@ -73,7 +73,7 @@ describe('Security Reports modal', () => { ...@@ -73,7 +73,7 @@ describe('Security Reports modal', () => {
}); });
it('emits dismissIssue when dismiss issue button is clicked', () => { it('emits dismissIssue when dismiss issue button is clicked', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit');
const button = vm.$el.querySelector('.js-dismiss-btn'); const button = vm.$el.querySelector('.js-dismiss-btn');
button.click(); button.click();
...@@ -104,7 +104,7 @@ describe('Security Reports modal', () => { ...@@ -104,7 +104,7 @@ describe('Security Reports modal', () => {
}); });
it('emits createIssue when create issue button is clicked', () => { it('emits createIssue when create issue button is clicked', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit');
const button = vm.$el.querySelector('.js-action-button'); const button = vm.$el.querySelector('.js-action-button');
button.click(); button.click();
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/sast_container_issue_body.vue'; import component from 'ee/vue_shared/security_reports/components/sast_container_issue_body.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
describe('sast container issue body', () => { describe('sast container issue body', () => {
let vm; let vm;
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/sast_issue_body.vue'; import component from 'ee/vue_shared/security_reports/components/sast_issue_body.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { STATUS_FAILED } from '~/reports/constants'; import { STATUS_FAILED } from '~/reports/constants';
describe('sast issue body', () => { describe('sast issue body', () => {
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/solution_card.vue'; import component from 'ee/vue_shared/security_reports/components/solution_card.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { trimText } from 'spec/helpers/vue_component_helper'; import { trimText } from 'helpers/vue_component_helper';
describe('Solution Card', () => { describe('Solution Card', () => {
const Component = Vue.extend(component); const Component = Vue.extend(component);
......
import Vue from 'vue'; import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/split_button.vue'; import component from 'ee/vue_shared/security_reports/components/split_button.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
describe('Split Button', () => { describe('Split Button', () => {
const Component = Vue.extend(component); const Component = Vue.extend(component);
...@@ -46,7 +46,7 @@ describe('Split Button', () => { ...@@ -46,7 +46,7 @@ describe('Split Button', () => {
}); });
it('emits the correct event when the button is pressed', () => { it('emits the correct event when the button is pressed', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit');
vm.$el.querySelector('.btn').click(); vm.$el.querySelector('.btn').click();
......
This diff is collapsed.
...@@ -22,6 +22,11 @@ import { ...@@ -22,6 +22,11 @@ import {
parsedDastNewIssues, parsedDastNewIssues,
parsedDast, parsedDast,
} from '../mock_data'; } from '../mock_data';
import { visitUrl } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrlMock'),
}));
describe('security reports mutations', () => { describe('security reports mutations', () => {
let stateCopy; let stateCopy;
...@@ -511,7 +516,6 @@ describe('security reports mutations', () => { ...@@ -511,7 +516,6 @@ describe('security reports mutations', () => {
describe('RECEIVE_CREATE_MERGE_REQUEST_SUCCESS', () => { describe('RECEIVE_CREATE_MERGE_REQUEST_SUCCESS', () => {
it('should fire the visitUrl function on the merge request URL', () => { it('should fire the visitUrl function on the merge request URL', () => {
const payload = { merge_request_path: 'fakepath.html' }; const payload = { merge_request_path: 'fakepath.html' };
const visitUrl = spyOnDependency(mutations, 'visitUrl');
mutations[types.RECEIVE_CREATE_MERGE_REQUEST_SUCCESS](stateCopy, payload); mutations[types.RECEIVE_CREATE_MERGE_REQUEST_SUCCESS](stateCopy, payload);
expect(visitUrl).toHaveBeenCalledWith(payload.merge_request_path); expect(visitUrl).toHaveBeenCalledWith(payload.merge_request_path);
......
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