CASH-2978 fix prereq tests
CASH-2978 fix prereq tests
This commit is contained in:
parent
b437ca183e
commit
b229d56abd
1 changed files with 74 additions and 15 deletions
|
|
@ -3,6 +3,9 @@ import { shallowMount } from "@vue/test-utils";
|
|||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import store from "@/store";
|
||||
import { applicationConfig } from "@/constants/application-config";
|
||||
import { coverageStatus } from "@/constants/insurance";
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
|
|
@ -37,14 +40,78 @@ describe("coverage-statement.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("methods", () => {
|
||||
test("arePagePrerequisitesValid returns true", () => {
|
||||
describe("arePagePrerequisitesValid", () => {
|
||||
test("returns true when all prerequisites are valid", () => {
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
expect(wrapper.vm.arePagePrerequisitesValid()).toBe(true);
|
||||
});
|
||||
|
||||
test("returns true when claim and coverage is selected, regardless of other prerequisites", () => {
|
||||
const { wrapper } = setupMocks();
|
||||
store.getters.order.payment.isClaimAndCoverage = true;
|
||||
store.getters.order.serviceLocation.zipCode = null;
|
||||
|
||||
expect(wrapper.vm.arePagePrerequisitesValid()).toBe(true);
|
||||
});
|
||||
|
||||
test("returns false when service zip info is missing", () => {
|
||||
const { wrapper } = setupMocks();
|
||||
store.getters.order.serviceLocation.zipCode = null;
|
||||
|
||||
expect(wrapper.vm.arePagePrerequisitesValid()).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false when glass parts or repair info is missing", () => {
|
||||
const { wrapper } = setupMocks();
|
||||
store.getters.order.damage.isRepair = false;
|
||||
store.getters.order.lineItems.glassParts = [];
|
||||
|
||||
expect(wrapper.vm.arePagePrerequisitesValid()).toBe(false);
|
||||
});
|
||||
|
||||
test("returns false when insurance info is invalid", () => {
|
||||
const { wrapper } = setupMocks();
|
||||
store.getters.order.payment.isInsurance = null;
|
||||
|
||||
expect(wrapper.vm.arePagePrerequisitesValid()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createValidOrderForCoverageStatement() {
|
||||
return {
|
||||
payment: {
|
||||
isClaimAndCoverage: false,
|
||||
isInsurance: false,
|
||||
parentAccountNumber: applicationConfig.CASH_PARENT_ACCOUNT_NUMBER,
|
||||
insuranceCoverage: {
|
||||
isVerified: true,
|
||||
coverageStatus: coverageStatus.VERIFIED,
|
||||
},
|
||||
},
|
||||
policy: {
|
||||
currentDeductible: 1000,
|
||||
policyNumber: "POL123",
|
||||
isItac: false,
|
||||
isNoComp: false,
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "00000",
|
||||
zipCodeCtu: "00000",
|
||||
},
|
||||
damage: {
|
||||
isRepair: false,
|
||||
},
|
||||
lineItems: {
|
||||
glassParts: [{ id: "part1", partType: "WINDSHIELD" }],
|
||||
promos: [],
|
||||
supportingItems: [],
|
||||
vaps: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function setupMocks() {
|
||||
const mockCmsContent = {
|
||||
FunnelHeaderWidget: { Text: "Header" },
|
||||
|
|
@ -55,6 +122,10 @@ function setupMocks() {
|
|||
fetchCmsContentForPage.mockResolvedValue(mockCmsContent);
|
||||
settleAllPromises.mockResolvedValue({ cmsContent: mockCmsContent });
|
||||
|
||||
store.getters = {
|
||||
order: createValidOrderForCoverageStatement(),
|
||||
};
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
route: { name: "duplicate-check", query: {}, params: {} },
|
||||
router: {
|
||||
|
|
@ -63,19 +134,7 @@ function setupMocks() {
|
|||
navigateWithoutSaving: jest.fn(),
|
||||
},
|
||||
store: {
|
||||
getters: {
|
||||
order: {
|
||||
policy: {
|
||||
currentDeductible: 1000,
|
||||
},
|
||||
lineItems: {
|
||||
glassParts: [],
|
||||
promos: [],
|
||||
supportingItems: [],
|
||||
vaps: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
getters: store.getters,
|
||||
},
|
||||
mixins: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue