EOD commit - unit testing for coverage statement
This commit is contained in:
parent
7310d43c1a
commit
219a8964de
2 changed files with 160 additions and 80 deletions
|
|
@ -1,115 +1,195 @@
|
||||||
// Components
|
// Components
|
||||||
import coverageStatement from "@/layouts/coverage-statement/coverage-statement.vue";
|
import coverageStatement from "@/layouts/coverage-statement/coverage-statement.vue";
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting files
|
||||||
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 vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
|
||||||
import baseFormMixin from "@/mixins/base-form-mixin";
|
import baseFormMixin from "@/mixins/base-form-mixin";
|
||||||
|
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||||
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
//import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
|
|
||||||
|
jest.mock("@/helpers/damage-helper", () => ({
|
||||||
|
getDamageString: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
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("display correct coverage statement", () => {
|
describe("method arePagePrerequisitesValid...", () => {
|
||||||
test("If damage is Repair, display NonADASRepairNextSteps statement", async () => {
|
test("Should return true for valid page requisites if carId exists", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
useMainStore().pageData = jest.fn();
|
useMainStore().lineItems = {
|
||||||
useMainStore().lineItems = { glassParts: null};
|
glassParts:
|
||||||
useMainStore().order.damage.isRepair = true;
|
[
|
||||||
|
{
|
||||||
const { wrapper, cmsContent } = setupMocks({});
|
partNumber: "DQ12204GTYNOEM",
|
||||||
|
requiresRecalibration: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
useMainStore().vehicle = { carId: "TEST_CAR_ID" };
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
//Act
|
//Assert
|
||||||
coverageStatement.beforeRouteEnter.call(
|
expect(result).toBe(true);
|
||||||
wrapper.vm,
|
|
||||||
{ query: { issPage: "coverage-statement" } },
|
|
||||||
undefined,
|
|
||||||
(c) => c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
wrapper.unmount();
|
||||||
expect(wrapper).toBeVisible();
|
});
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
test("Should return false for valid page requisites if carId is missing", () => {
|
||||||
|
// Arrange
|
||||||
|
useMainStore().lineItems = {
|
||||||
|
glassParts:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
partNumber: "DQ12204GTYNOEM",
|
||||||
|
requiresRecalibration: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
useMainStore().vehicle = { carId: null };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBeFalsy();
|
||||||
|
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockMixin = {
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn((contentName) => {
|
||||||
|
if (contentName === "UnverifiedADASNextStepsWidget") {
|
||||||
|
return "ADASReplaceTestReturn"
|
||||||
|
}
|
||||||
|
else if (contentName === "UnverifiedNonADASNextStepsWidget") {
|
||||||
|
return "NonADASReplaceTestReturn"
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
cmsWidgetName = "CMS widget name goes here",
|
cmsBodyText = "Body text goes here",
|
||||||
mountOptionsMockData = {
|
//pageHeaderWidgetHeaderText,
|
||||||
router: {
|
// mountOptionsMockData = {
|
||||||
navigate: jest.fn(),
|
// router: {
|
||||||
},
|
// navigate: jest.fn()
|
||||||
actionList: [
|
// },
|
||||||
{
|
// route: {
|
||||||
actionName: "getPartsOrQuestions",
|
// query: {
|
||||||
data: {},
|
// issPage: "coverage-statement",
|
||||||
},
|
// }
|
||||||
],
|
// }
|
||||||
route: {
|
// }
|
||||||
query: {
|
|
||||||
issPage: "coverage-statement",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
computedSwitcher: [
|
|
||||||
{
|
|
||||||
glassLocation: "Windshield",
|
|
||||||
glassName: "Single",
|
|
||||||
answerData: {
|
|
||||||
answerResult: "FW04848",
|
|
||||||
answeredQuestions: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
questionsData: {
|
|
||||||
get() {
|
|
||||||
return this.computedSwitcher;
|
|
||||||
},
|
|
||||||
set(val) {
|
|
||||||
this.computedSwitcher = val;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}) {
|
}) {
|
||||||
|
useMainStore().order = {
|
||||||
useMainStore().getPartsOrQuestions = jest.fn(() => {
|
vehicle: {
|
||||||
return {
|
carId: "TEST",
|
||||||
data: {
|
},
|
||||||
partsOrQuestions: [],
|
lineItems: {
|
||||||
|
glassParts: [
|
||||||
|
{
|
||||||
|
canSafeliteRecalibrate: false,
|
||||||
|
childParts: null,
|
||||||
|
color: "Green Tint",
|
||||||
|
description: "solar, driver side, encap",
|
||||||
|
partNumber: "DQ12204GTYNOEM",
|
||||||
|
partType: "DRIVER REAR QUARTER GLASS",
|
||||||
|
recalibrationType: null,
|
||||||
|
requiresCapabilityQuestions: false,
|
||||||
|
requiresRecalibration: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
damage: {
|
||||||
|
isRepair: false,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
...mountOptionsMockData,
|
// ...mountOptionsMockData,
|
||||||
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
// mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||||
});
|
});
|
||||||
mountOptions["attachTo"] = document.body;
|
//mountOptions["attachTo"] = document.body;
|
||||||
|
|
||||||
|
// const apiResponses = {
|
||||||
|
// 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
|
//Mock CMS content
|
||||||
const cmsContent = {
|
const cmsContent = {
|
||||||
Name: cmsWidgetName,
|
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 };
|
return { wrapper, cmsContent };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
cmsWidgetName="whatHappensNextCopy"
|
cmsWidgetName="whatHappensNextCopy"
|
||||||
class="mt-4 mb-2 fw-bold"
|
class="mt-4 mb-2 fw-bold"
|
||||||
/>
|
/>
|
||||||
<div v-html="bodyText"></div>
|
<div v-html="bodyText" ref="coverageStatementBodyText"></div>
|
||||||
<recalModal cmsWidgetName="RecalModal" />
|
<recalModal cmsWidgetName="RecalModal" />
|
||||||
<siteFooter
|
<siteFooter
|
||||||
cmsWidgetName="SiteFooterWidget"
|
cmsWidgetName="SiteFooterWidget"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue