extra needed for unit tests
This commit is contained in:
parent
a3293db761
commit
cc81fb4296
2 changed files with 17 additions and 9 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import buttonQuestion from "@/common-components/button-question/button-question";
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import analyticsMixIn from "@/mixins/analytics-mixin";
|
|
||||||
|
|
||||||
jest.mock("@/store", () => { return {}; }, { virtual: true });
|
jest.mock("@/store", () => { return {}; }, { virtual: true });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import buttonMain from "./button-main";
|
import buttonMain from "./button-main";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
|
|
||||||
describe("buttonMain.vue", () => {
|
describe("buttonMain.vue", () => {
|
||||||
it("Should return btn-primary class", async () => {
|
it("Should return btn-primary class", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(buttonMain, {
|
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||||
propsData: {
|
propsData: {
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const button = wrapper.find("button");
|
const button = wrapper.find("button");
|
||||||
|
|
@ -20,11 +21,11 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
it("Should return aria-disabled state", async () => {
|
it("Should return aria-disabled state", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(buttonMain, {
|
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||||
propsData: {
|
propsData: {
|
||||||
isDisabled: true,
|
isDisabled: true,
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
const button = wrapper.find("button");
|
const button = wrapper.find("button");
|
||||||
|
|
@ -35,12 +36,12 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
it("Should return loader color", async () => {
|
it("Should return loader color", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(buttonMain, {
|
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||||
propsData: {
|
propsData: {
|
||||||
loaderColor: "blue",
|
loaderColor: "blue",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
|
|
@ -57,12 +58,12 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
it("Should return loader position", async () => {
|
it("Should return loader position", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(buttonMain, {
|
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||||
propsData: {
|
propsData: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
|
|
@ -77,3 +78,11 @@ describe("buttonMain.vue", () => {
|
||||||
expect(loader.attributes("class")).toContain("right");
|
expect(loader.attributes("class")).toContain("right");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setupMocks(mountOptionsMockData = {}) {
|
||||||
|
const defaultMountOptions = { route: { query: { fmgPage: 'page-name' } } };
|
||||||
|
const baseMountOptions = getMountOptions(Object.assign(defaultMountOptions, mountOptionsMockData));
|
||||||
|
const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions);
|
||||||
|
|
||||||
|
return allMountOptions;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue