Added additional tests
This commit is contained in:
parent
8874519cb0
commit
97eaf64232
1 changed files with 74 additions and 11 deletions
|
|
@ -8,14 +8,15 @@ import baseMixin from "@/mixins/base-mixin";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
// Define Mocks
|
// Define Mocks
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
settleAllPromises: jest.fn()
|
settleAllPromises: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("@/helpers/cms-content-helper", () => ({
|
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||||
fetchCmsContentForPage: jest.fn()
|
fetchCmsContentForPage: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("@/store", () => ({
|
jest.mock("@/store", () => ({
|
||||||
|
|
@ -23,24 +24,88 @@ jest.mock("@/store", () => ({
|
||||||
dispatch: jest.fn(),
|
dispatch: jest.fn(),
|
||||||
getters: {
|
getters: {
|
||||||
lineItems: {
|
lineItems: {
|
||||||
supportingItems: null
|
supportingItems: [],
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
serviceLocation: {
|
serviceLocation: {
|
||||||
zipCode: null
|
zipCode: "00000",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
payment: {
|
payment: {
|
||||||
isInsurance: null
|
isInsurance: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store.getters = {
|
||||||
|
lineItems: {
|
||||||
|
supportingItems: [],
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
serviceLocation: {
|
||||||
|
zipCode: "00000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
payment: {
|
||||||
|
isInsurance: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
describe("service-location.vue", () => {
|
describe("service-location.vue", () => {
|
||||||
describe("arePagePrerequisitesValid", () => {
|
describe("arePagePrerequisitesValid", () => {
|
||||||
test("No prerequisites set: Should return false.", async () => {
|
test("No prerequisites set: Should return false.", async () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
store.getters = {
|
||||||
|
lineItems: {
|
||||||
|
supportingItems: null,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
serviceLocation: {
|
||||||
|
zipCode: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
payment: {
|
||||||
|
isInsurance: null,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
serviceLocation.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "service-location" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
expect(arePagePrerequisitesValid).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("All prerequisites set: Should return true.", async () => {
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
serviceLocation.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "service-location" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Some prerequisites set: Should return false.", async () => {
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
store.getters.order.serviceLocation.zipCode = null;
|
||||||
|
|
||||||
serviceLocation.beforeRouteEnter.call(
|
serviceLocation.beforeRouteEnter.call(
|
||||||
wrapper.vm,
|
wrapper.vm,
|
||||||
{ query: { fmgPage: "service-location" } },
|
{ query: { fmgPage: "service-location" } },
|
||||||
|
|
@ -56,9 +121,7 @@ describe("service-location.vue", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({ mountOptionsMockData = {} }) {
|
||||||
mountOptionsMockData = {}
|
|
||||||
}) {
|
|
||||||
const apiResponses = {};
|
const apiResponses = {};
|
||||||
|
|
||||||
const apiPromise = Promise.resolve(apiResponses);
|
const apiPromise = Promise.resolve(apiResponses);
|
||||||
|
|
@ -71,4 +134,4 @@ function setupMocks({
|
||||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||||
|
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue