From 0ecce77df3bac92453253233eafd643cfa358975 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 28 Sep 2022 00:27:50 -0400 Subject: [PATCH] Adjust unit test --- .../Workflow/WorkflowIndexActions.test.js | 21 ++++++++++++------- .../Workflow/WorkflowIndexActions.vue | 6 ------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/src/components/Workflow/WorkflowIndexActions.test.js b/client/src/components/Workflow/WorkflowIndexActions.test.js index e59eac231ed..067c94caa28 100644 --- a/client/src/components/Workflow/WorkflowIndexActions.test.js +++ b/client/src/components/Workflow/WorkflowIndexActions.test.js @@ -2,33 +2,40 @@ import WorkflowIndexActions from "./WorkflowIndexActions"; import { shallowMount } from "@vue/test-utils"; import { getLocalVue } from "jest/helpers"; import { ROOT_COMPONENT } from "utils/navigation"; +import VueRouter from "vue-router"; import "jest-location-mock"; const localVue = getLocalVue(true); +localVue.use(VueRouter); -describe("WorkflowIndexActions.vue", () => { +const router = new VueRouter(); + +function getCurrentPath($router) { + return $router.history.current.path; +} + +describe("WorkflowIndexActions", () => { let wrapper; + let $router; beforeEach(async () => { - const propsData = { - root: "/root/", - }; wrapper = shallowMount(WorkflowIndexActions, { - propsData, localVue, + router, }); + $router = wrapper.vm.$router; }); describe("naviation", () => { it("should create a workflow when create is clicked", async () => { await wrapper.find(ROOT_COMPONENT.workflows.new_button.selector).trigger("click"); - expect(window.location).toBeAt("/root/workflows/create"); + expect(getCurrentPath($router)).toBe("/workflows/create"); }); it("should import a workflow when create is clicked", async () => { await wrapper.find(ROOT_COMPONENT.workflows.import_button.selector).trigger("click"); - expect(window.location).toBeAt("/root/workflows/import"); + expect(getCurrentPath($router)).toBe("/workflows/import"); }); it("should localize button text", async () => { diff --git a/client/src/components/Workflow/WorkflowIndexActions.vue b/client/src/components/Workflow/WorkflowIndexActions.vue index 5cd03187549..c71c430451f 100644 --- a/client/src/components/Workflow/WorkflowIndexActions.vue +++ b/client/src/components/Workflow/WorkflowIndexActions.vue @@ -24,12 +24,6 @@ export default { BButton, FontAwesomeIcon, }, - props: { - root: { - type: String, - required: true, - }, - }, methods: { navigateToCreate: function () { this.$router.push("/workflows/create");