Added first basic test
This commit is contained in:
parent
30e3ddc541
commit
8874519cb0
1 changed files with 72 additions and 1 deletions
|
|
@ -1,3 +1,74 @@
|
||||||
|
// Components
|
||||||
|
import serviceLocation from "@/layouts/service-location/service-location.vue";
|
||||||
|
|
||||||
|
// Supporting files
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper";
|
||||||
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
|
import { nextTick } from "vue";
|
||||||
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
|
|
||||||
|
// Define Mocks
|
||||||
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
settleAllPromises: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||||
|
fetchCmsContentForPage: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock("@/store", () => ({
|
||||||
|
commit: jest.fn(),
|
||||||
|
dispatch: jest.fn(),
|
||||||
|
getters: {
|
||||||
|
lineItems: {
|
||||||
|
supportingItems: null
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
serviceLocation: {
|
||||||
|
zipCode: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
payment: {
|
||||||
|
isInsurance: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
describe("service-location.vue", () => {
|
describe("service-location.vue", () => {
|
||||||
test.todo("test this");
|
describe("arePagePrerequisitesValid", () => {
|
||||||
|
test("No prerequisites set: Should return false.", 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(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
mountOptionsMockData = {}
|
||||||
|
}) {
|
||||||
|
const apiResponses = {};
|
||||||
|
|
||||||
|
const apiPromise = Promise.resolve(apiResponses);
|
||||||
|
|
||||||
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
const mountOptions = getMountOptions(mountOptionsMockData);
|
||||||
|
const wrapper = shallowMount(serviceLocation, mountOptions);
|
||||||
|
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||||
|
|
||||||
|
return { wrapper, apiPromise };
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue