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 buttonQuestion from "@/common-components/button-question/button-question";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import analyticsMixIn from "@/mixins/analytics-mixin";
|
||||
|
||||
jest.mock("@/store", () => { return {}; }, { virtual: true });
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import { shallowMount } from "@vue/test-utils";
|
||||
import buttonMain from "./button-main";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { nextTick } from "vue";
|
||||
|
||||
describe("buttonMain.vue", () => {
|
||||
it("Should return btn-primary class", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(buttonMain, {
|
||||
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||
propsData: {
|
||||
isPrimary: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
// Assert
|
||||
const button = wrapper.find("button");
|
||||
|
|
@ -20,11 +21,11 @@ describe("buttonMain.vue", () => {
|
|||
|
||||
it("Should return aria-disabled state", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(buttonMain, {
|
||||
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||
propsData: {
|
||||
isDisabled: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
// Assert
|
||||
const button = wrapper.find("button");
|
||||
|
|
@ -35,12 +36,12 @@ describe("buttonMain.vue", () => {
|
|||
|
||||
it("Should return loader color", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(buttonMain, {
|
||||
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||
propsData: {
|
||||
loaderColor: "blue",
|
||||
loaderEnabled: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
// Assert
|
||||
|
||||
|
|
@ -57,12 +58,12 @@ describe("buttonMain.vue", () => {
|
|||
|
||||
it("Should return loader position", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(buttonMain, {
|
||||
const wrapper = shallowMount(buttonMain, setupMocks({
|
||||
propsData: {
|
||||
loaderPosition: "right",
|
||||
loaderEnabled: true,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
// Assert
|
||||
|
||||
|
|
@ -77,3 +78,11 @@ describe("buttonMain.vue", () => {
|
|||
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