display correct coverage statement unit tests
This commit is contained in:
parent
219a8964de
commit
b3bb54a2ba
2 changed files with 126 additions and 110 deletions
|
|
@ -5,10 +5,10 @@ import coverageStatement from "@/layouts/coverage-statement/coverage-statement.v
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { useMainStore } from "@/store";
|
import { useMainStore } from "@/store";
|
||||||
import baseFormMixin from "@/mixins/base-form-mixin";
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
//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";
|
||||||
|
|
||||||
jest.mock("@/helpers/damage-helper", () => ({
|
jest.mock("@/helpers/damage-helper", () => ({
|
||||||
|
|
@ -20,62 +20,105 @@ jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
settleAllPromises: jest.fn(),
|
settleAllPromises: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// // Mock fetchCmsContentForPage
|
// Mock fetchCmsContentForPage
|
||||||
// jest.mock("@/helpers/cms-content-helper", () => ({
|
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||||
// fetchCmsContentForPage: jest.fn(),
|
fetchCmsContentForPage: jest.fn(),
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
describe("coverage-statement.vue...", () => {
|
describe("coverage-statement.vue...", () => {
|
||||||
describe("method arePagePrerequisitesValid...", () => {
|
describe("method arePagePrerequisitesValid...", () => {
|
||||||
test("Should return true for valid page requisites if carId exists", () => {
|
test("Should return true for valid page requisites if vin exists", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
useMainStore().lineItems = {
|
|
||||||
glassParts:
|
|
||||||
[
|
|
||||||
{
|
|
||||||
partNumber: "DQ12204GTYNOEM",
|
|
||||||
requiresRecalibration: false,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
useMainStore().vehicle = { carId: "TEST_CAR_ID" };
|
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(result).toBe(true);
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Should return false for valid page requisites if carId is missing", () => {
|
test("Should return false for valid page requisites if vin is missing", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
useMainStore().lineItems = {
|
|
||||||
glassParts:
|
|
||||||
[
|
|
||||||
{
|
|
||||||
partNumber: "DQ12204GTYNOEM",
|
|
||||||
requiresRecalibration: false,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
useMainStore().vehicle = { carId: null };
|
useMainStore().order.vehicle.vin = null;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(result).toBeFalsy();
|
expect(arePagePrerequisitesValid).toBe(false);
|
||||||
|
|
||||||
wrapper.unmount();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("navigation", () => {
|
||||||
|
// test("Vehicle has part questions, navigateBack triggers a router.navigate change with correct scenario", async () => {
|
||||||
|
// //Arrange
|
||||||
|
// const { wrapper } = setupMocks({
|
||||||
|
// mountOptionsMockData: {
|
||||||
|
// router: {
|
||||||
|
// navigate: jest.fn(),
|
||||||
|
// },
|
||||||
|
// route: {
|
||||||
|
// query: {
|
||||||
|
// issPage: "coverage-statement",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// //Act
|
||||||
|
// coverageStatement.beforeRouteEnter.call(
|
||||||
|
// wrapper.vm,
|
||||||
|
// { query: { issPage: "coverage-statement" } },
|
||||||
|
// undefined,
|
||||||
|
// (c) => c(wrapper.vm)
|
||||||
|
// );
|
||||||
|
|
||||||
|
// wrapper.vm.navigateBack();
|
||||||
|
|
||||||
|
// //Assert
|
||||||
|
// expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
// navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
|
||||||
|
// wrapper.vm.$route
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
describe("display correct coverage statement", () => {
|
||||||
|
test("If damage is Repair, display NonADASRepair coverage statement", async () => {
|
||||||
|
// Arrange
|
||||||
|
const wrapper = shallowMount(coverageStatement, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
});
|
||||||
|
|
||||||
|
useMainStore().order.damage.isRepair = true;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.unverifiedNonADASRepairBodyText).toEqual("NonADASRepairTestReturn");
|
||||||
|
})
|
||||||
|
|
||||||
|
test("If damage is NonADAS Replace, display NonADASReplace coverage statement", async () => {
|
||||||
|
// Arrange
|
||||||
|
const wrapper = shallowMount(coverageStatement, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.unverifiedNonADASNextStepsBodyText).toEqual("NonADASReplaceTestReturn");
|
||||||
|
})
|
||||||
|
|
||||||
|
test("If damage is ADAS Replace, display ADASReplace coverage statement", async () => {
|
||||||
|
// Arrange
|
||||||
|
const wrapper = shallowMount(coverageStatement, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
});
|
||||||
|
|
||||||
|
useMainStore().order.lineItems.requiresRecalibration = true;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.unverifiedADASNextStepsBodyText).toEqual("ADASReplaceTestReturn");
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
|
|
@ -84,6 +127,9 @@ const mockMixin = {
|
||||||
if (contentName === "UnverifiedADASNextStepsWidget") {
|
if (contentName === "UnverifiedADASNextStepsWidget") {
|
||||||
return "ADASReplaceTestReturn"
|
return "ADASReplaceTestReturn"
|
||||||
}
|
}
|
||||||
|
else if (contentName === "UnverifiedNonADASRepairWidget") {
|
||||||
|
return "NonADASRepairTestReturn"
|
||||||
|
}
|
||||||
else if (contentName === "UnverifiedNonADASNextStepsWidget") {
|
else if (contentName === "UnverifiedNonADASNextStepsWidget") {
|
||||||
return "NonADASReplaceTestReturn"
|
return "NonADASReplaceTestReturn"
|
||||||
}
|
}
|
||||||
|
|
@ -93,22 +139,30 @@ const mockMixin = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
cmsBodyText = "Body text goes here",
|
pageHeaderWidgetHeaderText,
|
||||||
//pageHeaderWidgetHeaderText,
|
// cmsPageContent = "CMS content goes here",
|
||||||
// mountOptionsMockData = {
|
// unverifiedNonADASRepairBodyText = "repair body text",
|
||||||
// router: {
|
|
||||||
// navigate: jest.fn()
|
|
||||||
// },
|
|
||||||
// route: {
|
|
||||||
// query: {
|
|
||||||
// issPage: "coverage-statement",
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}) {
|
}) {
|
||||||
|
//Mock api responses
|
||||||
|
const apiResponses = {
|
||||||
|
cmsContent: {
|
||||||
|
SiteSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||||
|
FunnelHeaderWidget: {
|
||||||
|
LogoImage:
|
||||||
|
`${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`,
|
||||||
|
},
|
||||||
|
ColorQuestionWidget: "Please choose your rear window tint color",
|
||||||
|
FeatureQuestionWidget: "Ok no choose features",
|
||||||
|
AlertWidget: {
|
||||||
|
BodyText: "Please choose your tint color",
|
||||||
|
HeadlineText: "Just a few more steps to go",
|
||||||
|
},
|
||||||
|
unverifiedNonADASRepairBodyText: "Repair body text",
|
||||||
|
},
|
||||||
|
};
|
||||||
useMainStore().order = {
|
useMainStore().order = {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
carId: "TEST",
|
vin: "TESTVIN",
|
||||||
},
|
},
|
||||||
lineItems: {
|
lineItems: {
|
||||||
glassParts: [
|
glassParts: [
|
||||||
|
|
@ -129,67 +183,29 @@ function setupMocks({
|
||||||
isRepair: false,
|
isRepair: false,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const apiPromise = Promise.resolve(apiResponses);
|
||||||
|
|
||||||
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
// ...mountOptionsMockData,
|
|
||||||
// mixins: [baseFormMixin, vehicleQuestionsMixin],
|
|
||||||
});
|
});
|
||||||
//mountOptions["attachTo"] = document.body;
|
|
||||||
|
|
||||||
// const apiResponses = {
|
mountOptions.mixins = [baseMixin, vehicleQuestionsMixin];
|
||||||
// cmsContent: {
|
|
||||||
// SiteHeaderWidget: {
|
|
||||||
// LogoImage:
|
|
||||||
// `${applicationConfig.ISS_DEV_CMS_DOMAIN}/images/default-source/default-album/logos/insuranceLogo.jpg`,
|
|
||||||
// },
|
|
||||||
// SiteSubHeaderWidget: pageHeaderWidgetHeaderText,
|
|
||||||
// verifyingCoverageStatement: "We're verifying your coverage",
|
|
||||||
// continueWithSchedulingCopy: "Go ahead and continue with scheduling while we verify your coverage. We'll let you know what deductible amount, if any, applies.",
|
|
||||||
// whatHappensNextCopy: "What happens next:",
|
|
||||||
// UnverifiedADASNextStepsWidget: {
|
|
||||||
// BodyText: "ADASReplace body text goes here",
|
|
||||||
// },
|
|
||||||
// UnverifiedNonADASNextStepsWidget: {
|
|
||||||
// BodyText: "NonADASReplace body text goes here",
|
|
||||||
// },
|
|
||||||
// UnverifiedNonADASRepairWidget: {
|
|
||||||
// BodyText: "NonADASRepair body text goes here",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// const apiResponses = {
|
|
||||||
// cmsContent: {},
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
mountOptions.mixins = [mockMixin];
|
|
||||||
//settleAllPromises.mockImplementation(() => apiResponses);
|
|
||||||
//fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
|
||||||
|
|
||||||
const wrapper = shallowMount(coverageStatement, mountOptions);
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
|
||||||
//Mock CMS content
|
|
||||||
const cmsContent = {
|
|
||||||
BodyText: cmsBodyText,
|
|
||||||
// UnverifiedADASNextStepsWidget: {
|
|
||||||
// BodyText: "ADASReplace body text goes here",
|
|
||||||
// },
|
|
||||||
// UnverifiedNonADASNextStepsWidget: {
|
|
||||||
// BodyText: "NonADASReplace body text goes here",
|
|
||||||
// },
|
|
||||||
// UnverifiedNonADASRepairWidget: {
|
|
||||||
// BodyText: "NonADASRepair body text goes here",
|
|
||||||
// },
|
|
||||||
};
|
|
||||||
|
|
||||||
//wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
|
||||||
//wrapper.vm.setCmsContent = jest.fn();
|
|
||||||
|
|
||||||
return { wrapper, cmsContent };
|
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||||
|
|
||||||
|
|
||||||
|
// //Mock CMS content
|
||||||
|
// const cmsContent = {
|
||||||
|
// PageContent: cmsPageContent,
|
||||||
|
// NonADASRepairBodyText: unverifiedNonADASRepairBodyText,
|
||||||
|
// };
|
||||||
|
|
||||||
|
return { wrapper };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,16 +84,16 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
continueWithSchedulingBodyText() {
|
continueWithSchedulingBodyText() {
|
||||||
return this.getCmsContent('continueWithSchedulingCopy', 'BodyText');
|
return this.getCmsContent("continueWithSchedulingCopy", "BodyText");
|
||||||
},
|
},
|
||||||
unverifiedADASNextStepsBodyText() {
|
unverifiedADASNextStepsBodyText() {
|
||||||
return this.getCmsContent('UnverifiedADASNextStepsWidget', 'BodyText').replaceAll("{custom:damage}", this.damageText);
|
return this.getCmsContent("UnverifiedADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
|
||||||
},
|
},
|
||||||
unverifiedNonADASNextStepsBodyText() {
|
unverifiedNonADASNextStepsBodyText() {
|
||||||
return this.getCmsContent('UnverifiedNonADASNextStepsWidget', 'BodyText').replaceAll("{custom:damage}", this.damageText);
|
return this.getCmsContent("UnverifiedNonADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
|
||||||
},
|
},
|
||||||
unverifiedNonADASRepairBodyText() {
|
unverifiedNonADASRepairBodyText() {
|
||||||
return this.getCmsContent('UnverifiedNonADASRepairWidget', 'BodyText');
|
return this.getCmsContent("UnverifiedNonADASRepairWidget", "BodyText");
|
||||||
},
|
},
|
||||||
damageText() {
|
damageText() {
|
||||||
var damageString = getDamageString();
|
var damageString = getDamageString();
|
||||||
|
|
@ -120,7 +120,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
if (useMainStore().order.vehicle.carId) {
|
if (useMainStore().order.vehicle.vin) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue