Adjust unit test

This commit is contained in:
guerler
2022-09-28 00:59:08 -04:00
parent 37a00c2aa5
commit 0ecce77df3
2 changed files with 14 additions and 13 deletions
@@ -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 () => {
@@ -24,12 +24,6 @@ export default {
BButton,
FontAwesomeIcon,
},
props: {
root: {
type: String,
required: true,
},
},
methods: {
navigateToCreate: function () {
this.$router.push("/workflows/create");