Split and adapt unit tests

This commit is contained in:
davelopez
2022-06-15 11:26:53 +02:00
parent e28914705e
commit 48153a9f67
2 changed files with 82 additions and 20 deletions
@@ -34,16 +34,6 @@ describe("WorkflowInvocationState.vue with terminal invocation", () => {
it("determines that invocation and job states are terminal", async () => {
expect(wrapper.vm.invocationAndJobTerminal).toBeTruthy();
});
it("displays report links", async () => {
expect(wrapper.find(".invocation-pdf-link").exists()).toBeTruthy();
expect(wrapper.find(".invocation-report-link").exists()).toBeTruthy();
expect(wrapper.find(".bco-json").exists()).toBeTruthy();
});
it("doesn't show cancel invocation button", async () => {
expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeFalsy();
});
});
describe("WorkflowInvocationState.vue with no invocation", () => {
@@ -77,14 +67,4 @@ describe("WorkflowInvocationState.vue with no invocation", () => {
it("determines that invocation and job states are not terminal", async () => {
expect(wrapper.vm.invocationAndJobTerminal).toBeFalsy();
});
it("does not display report links", async () => {
expect(wrapper.find(".invocation-pdf-link").exists()).toBeFalsy();
expect(wrapper.find(".invocation-report-link").exists()).toBeFalsy();
expect(wrapper.find(".bco-json").exists()).toBeFalsy();
});
it("shows cancel invocation button", async () => {
expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeTruthy();
});
});
@@ -0,0 +1,82 @@
import WorkflowInvocationSummary from "./WorkflowInvocationSummary";
import { shallowMount } from "@vue/test-utils";
import { getLocalVue } from "jest/helpers";
import Vuex from "vuex";
import invocationData from "../Workflow/test/json/invocation.json";
const invocationJobsSummaryById = {
id: "d9833097445452b0",
model: "WorkflowInvocation",
states: {},
populated_state: "ok",
};
const mockComputed = {
getInvocationJobsSummaryById: () => () => invocationJobsSummaryById,
};
const localVue = getLocalVue();
describe("WorkflowInvocationSummary.vue with terminal invocation", () => {
let wrapper;
let propsData;
beforeEach(async () => {
propsData = {
invocation: invocationData,
invocationAndJobTerminal: true,
invocationSchedulingTerminal: true,
};
wrapper = shallowMount(WorkflowInvocationSummary, {
propsData,
computed: mockComputed,
localVue,
});
});
it("displays report links", async () => {
expect(wrapper.find(".invocation-pdf-link").exists()).toBeTruthy();
expect(wrapper.find(".invocation-report-link").exists()).toBeTruthy();
});
it("doesn't show cancel invocation button", async () => {
expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeFalsy();
});
});
describe("WorkflowInvocationSummary.vue with invocation scheduling running", () => {
let wrapper;
let propsData;
let store;
let actions;
beforeEach(async () => {
actions = {
fetchInvocationForId: jest.fn(),
fetchInvocationJobsSummaryForId: jest.fn(),
};
store = new Vuex.Store({
actions,
});
propsData = {
invocation: invocationData,
invocationAndJobTerminal: false,
invocationSchedulingTerminal: false,
};
wrapper = shallowMount(WorkflowInvocationSummary, {
store,
propsData,
computed: mockComputed,
localVue,
});
});
it("does not display report links", async () => {
expect(wrapper.find(".invocation-pdf-link").exists()).toBeFalsy();
expect(wrapper.find(".invocation-report-link").exists()).toBeFalsy();
});
it("shows cancel invocation button", async () => {
expect(wrapper.find(".cancel-workflow-scheduling").exists()).toBeTruthy();
});
});