remove unit tests for now
This commit is contained in:
parent
4d27a95b1c
commit
dd28b1371c
1 changed files with 0 additions and 220 deletions
|
|
@ -1,220 +0,0 @@
|
|||
// Components
|
||||
import coverageStatement from "@/layouts/coverage-statement/coverage-statement.vue";
|
||||
|
||||
// Supporting files
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { useMainStore } from "@/store";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||
import { applicationConfig } from "@/constants/application-config";
|
||||
import { fetchCmsContentForPage, setupModalLinks } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { getRandomString } from '@/helpers/data-generation.js';
|
||||
|
||||
jest.mock("@/helpers/damage-helper", () => ({
|
||||
getDamageString: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
settleAllPromises: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock fetchCmsContentForPage, setupModalLinks
|
||||
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||
fetchCmsContentForPage: jest.fn(),
|
||||
setupModalLinks: jest.fn(),
|
||||
}));
|
||||
|
||||
describe("coverage-statement.vue...", () => {
|
||||
describe("method arePagePrerequisitesValid...", () => {
|
||||
test.only("Should return true for valid page requisites if vin exists", () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
const store = useMainStore();
|
||||
store.order.vehicle.vin = getRandomString(5,20);
|
||||
|
||||
// Act
|
||||
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||
|
||||
//Assert
|
||||
expect(arePagePrerequisitesValid).toBe(true);
|
||||
});
|
||||
|
||||
test("Should return false for valid page requisites if vin is missing", () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
const store = useMainStore();
|
||||
store.order.vehicle.vin = null;
|
||||
|
||||
// Act
|
||||
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||
|
||||
//Assert
|
||||
expect(arePagePrerequisitesValid).toBe(false);
|
||||
});
|
||||
});
|
||||
describe("navigation", () => {
|
||||
test("forwardButtonAction should trigger navigateForward", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
wrapper.vm.navigateForward = jest.fn();
|
||||
|
||||
// Act
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe("display correct coverage statement", () => {
|
||||
test("If damage is Repair, display NonADASRepair coverage statement", async () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(coverageStatement, {
|
||||
mixins: [mockMixin],
|
||||
});
|
||||
const store = useMainStore();
|
||||
store.order.damage.isRepair = true;
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.bodyText).toEqual("NonADASRepairTestReturn");
|
||||
})
|
||||
|
||||
test("If damage is NonADAS Replace, display NonADASReplace coverage statement", async () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(coverageStatement, {
|
||||
mixins: [mockMixin],
|
||||
});
|
||||
|
||||
const store = useMainStore();
|
||||
store.lineItems.glassParts =
|
||||
[
|
||||
{
|
||||
requiresRecalibration: false,
|
||||
}
|
||||
];
|
||||
store.order.damage.isRepair = false;
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.bodyText).toEqual("NonADASReplaceTestReturn");
|
||||
})
|
||||
|
||||
test("If damage is ADAS Replace, display ADASReplace coverage statement", async () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(coverageStatement, {
|
||||
mixins: [mockMixin],
|
||||
});
|
||||
const store = useMainStore();
|
||||
store.lineItems.glassParts = [
|
||||
{
|
||||
requiresRecalibration: true,
|
||||
}
|
||||
];
|
||||
store.order.damage.isRepair = false;
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.bodyText).toEqual("ADASReplaceTestReturn");
|
||||
})
|
||||
});
|
||||
describe("claim registration api call", () => {
|
||||
it("claim registration not required => method not called", async () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({});
|
||||
|
||||
const store = useMainStore();
|
||||
store.isClaimRegistrationRequired = false;
|
||||
|
||||
const to = {
|
||||
query: { issPage: getRandomString(4,10) }
|
||||
};
|
||||
const next = jest.fn();
|
||||
|
||||
// SUT
|
||||
coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next)
|
||||
|
||||
// Assert
|
||||
expect(store.registerClaim).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("claim registration required => register claim method called", async () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({});
|
||||
|
||||
const store = useMainStore();
|
||||
store.isClaimRegistrationRequired = true;
|
||||
|
||||
const to = {
|
||||
query: { issPage: getRandomString(4,10) }
|
||||
};
|
||||
const next = jest.fn();
|
||||
|
||||
// SUT
|
||||
coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next)
|
||||
|
||||
// Assert
|
||||
expect(store.registerClaim).toHaveBeenCalled();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn((contentName) => {
|
||||
if (contentName === "UnverifiedADASNextStepsWidget") {
|
||||
return "ADASReplaceTestReturn"
|
||||
}
|
||||
else if (contentName === "UnverifiedNonADASRepairWidget") {
|
||||
return "NonADASRepairTestReturn"
|
||||
}
|
||||
else if (contentName === "UnverifiedNonADASNextStepsWidget") {
|
||||
return "NonADASReplaceTestReturn"
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
function setupMocks({
|
||||
pageHeaderWidgetHeaderText,
|
||||
mountOptionsMockData = {},
|
||||
}) {
|
||||
//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",
|
||||
},
|
||||
};
|
||||
|
||||
const apiPromise = Promise.resolve(apiResponses);
|
||||
|
||||
settleAllPromises.mockImplementation(() => apiPromise);
|
||||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||
|
||||
const mountOptions = getMountOptions({});
|
||||
|
||||
mountOptions.mixins = [baseMixin, vehicleQuestionsMixin];
|
||||
mountOptions.global = {
|
||||
plugins: [createTestingPinia()]
|
||||
}
|
||||
|
||||
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||
|
||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue