Update unit tests
This commit is contained in:
parent
3945113287
commit
809d1838df
3 changed files with 340 additions and 205 deletions
|
|
@ -49,6 +49,7 @@ const storeMutations = {
|
||||||
UPDATE_BILL_TO_ACCT_NUMBER: "updateBillToAcctNumber",
|
UPDATE_BILL_TO_ACCT_NUMBER: "updateBillToAcctNumber",
|
||||||
UPDATE_EON: "updateEON",
|
UPDATE_EON: "updateEON",
|
||||||
UPDATE_IS_INSURANCE: "updateIsInsurance",
|
UPDATE_IS_INSURANCE: "updateIsInsurance",
|
||||||
|
UPDATE_IS_VERIFIED_INSURANCE: "updateInsuranceVerifiedStatus",
|
||||||
UPDATE_SAVED_SESSION_ID: "updateSavedSessionId",
|
UPDATE_SAVED_SESSION_ID: "updateSavedSessionId",
|
||||||
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
|
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
|
||||||
UPDATE_IS_PIA: "updateIsPia",
|
UPDATE_IS_PIA: "updateIsPia",
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}) {
|
||||||
/*
|
/*
|
||||||
* Send the user to the specified page, except in specific scenarios.
|
* Send the user to the specified page, except in specific scenarios.
|
||||||
*/
|
*/
|
||||||
async function getDirectNavigation(toRoute) {
|
export async function getDirectNavigation(toRoute) {
|
||||||
const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE];
|
const fmgPageValue = toRoute.query[queryStrings.FMG_PAGE];
|
||||||
|
|
||||||
// Override if Verified Insurance & Trying to go to vehicle
|
// Override if Verified Insurance & Trying to go to vehicle
|
||||||
|
|
@ -47,7 +47,7 @@ async function getDirectNavigation(toRoute) {
|
||||||
* General strategy: run through pages in reverse order, and select first where prerequisites are valid.
|
* General strategy: run through pages in reverse order, and select first where prerequisites are valid.
|
||||||
* QUOTE is the latest page to send to.
|
* QUOTE is the latest page to send to.
|
||||||
*/
|
*/
|
||||||
async function getImplicitNavigation(toRoute) {
|
export async function getImplicitNavigation(toRoute) {
|
||||||
const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE);
|
const vehicleDamageComponent = await getLazyLoadedComponent(fmgPageValues.VEHICLE_DAMAGE);
|
||||||
const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE);
|
const estimateComponent = await getLazyLoadedComponent(fmgPageValues.ESTIMATE);
|
||||||
const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP);
|
const vinLookupComponent = await getLazyLoadedComponent(fmgPageValues.VIN_LOOKUP);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import * as navigationHelper from "@/helpers/heritage-integration/navigation-helper";
|
||||||
getPageToRouteExistingOrderTo,
|
|
||||||
navigateToHeritageFunnel,
|
|
||||||
} from "@/helpers/heritage-integration/navigation-helper";
|
|
||||||
import * as orderHelper from "@/helpers/heritage-integration/order-helper";
|
import * as orderHelper from "@/helpers/heritage-integration/order-helper";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
@ -14,233 +11,370 @@ import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
|
||||||
|
const getPageToRouteExistingOrderTo = navigationHelper.getPageToRouteExistingOrderTo;
|
||||||
|
const navigateToHeritageFunnel = navigationHelper.navigateToHeritageFunnel;
|
||||||
|
|
||||||
// Mock Lazy Load
|
// Mock Lazy Load
|
||||||
jest.mock("@/router/dynamic-routing/component-loader.js", () => ({
|
jest.mock("@/router/dynamic-routing/component-loader.js", () => ({
|
||||||
lazyLoadComponent: jest.fn(),
|
lazyLoadComponent: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("getPageToRouteExistingOrderTo", () => {
|
describe("getPageToRouteExistingOrderTo", () => {
|
||||||
test("should return vehicle", async () => {
|
describe("Explicit vs. Implicit Routing", () => {
|
||||||
// Arrange
|
test("Should call explicit routing if `fmgPage` parameter is present in query", async () => {
|
||||||
const toRoute = {
|
// Arrange
|
||||||
query: {},
|
const toRoute = {
|
||||||
};
|
query: {
|
||||||
|
fmgPage: "schedule",
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(fmgPageValues.VEHICLE);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return vehicle-damage", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
|
||||||
[fmgPageValues.ESTIMATE]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("user has YMMS and no vehicle questions > should return estimate", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
|
||||||
|
|
||||||
const mockExperimentsList = [
|
|
||||||
{
|
|
||||||
universeName: "ConceptFunnel",
|
|
||||||
settings: {
|
|
||||||
SuppressVinCapture: false,
|
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
];
|
|
||||||
store.commit(storeMutations.UPDATE_EXPERIMENTS, mockExperimentsList);
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
mockLazyLoadComponentReturnValues();
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
// Act
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
// Assert
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
// If direct, should be "schedule".
|
||||||
[fmgPageValues.VEHICLE_PARTS]: false,
|
// Otherwise, not.
|
||||||
[fmgPageValues.PART_QUESTIONS]: false,
|
expect(result).toBe("schedule");
|
||||||
[fmgPageValues.VIN_LOOKUP]: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
test("Should call implicit routing if `fmgPage` parameter is NOT present in query", async () => {
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
//Assert
|
mockLazyLoadComponentReturnValues();
|
||||||
expect(result).toBe(fmgPageValues.ESTIMATE);
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
// If direct, should be "schedule".
|
||||||
|
// Otherwise, not.
|
||||||
|
expect(result).not.toBe("schedule");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("user has YMMS but no questions or carId > should return estimate", async () => {
|
describe("Implicit Routing", () => {
|
||||||
// Arrange
|
test("should return vehicle", async () => {
|
||||||
const toRoute = {
|
// Arrange
|
||||||
query: {},
|
const toRoute = {
|
||||||
};
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
// Mock out the lazy load calls for all components.
|
||||||
mockLazyLoadComponentReturnValues({
|
mockLazyLoadComponentReturnValues({
|
||||||
[fmgPageValues.VEHICLE]: true,
|
[fmgPageValues.VEHICLE]: true,
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
[fmgPageValues.VEHICLE_DAMAGE]: false,
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
});
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
// Act
|
||||||
[fmgPageValues.VEHICLE_PARTS]: false,
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
[fmgPageValues.PART_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.VIN_LOOKUP]: false,
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.VEHICLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
test("should return vehicle-damage", async () => {
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
//Assert
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
expect(result).toBe(fmgPageValues.ESTIMATE);
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has YMMS and no vehicle questions > should return estimate", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
const mockExperimentsList = [
|
||||||
|
{
|
||||||
|
universeName: "ConceptFunnel",
|
||||||
|
settings: {
|
||||||
|
SuppressVinCapture: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
store.commit(storeMutations.UPDATE_EXPERIMENTS, mockExperimentsList);
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.ESTIMATE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has YMMS but no questions or carId > should return estimate", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.ESTIMATE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has capability questions and molding questions > should return capability questions", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has molding questions and part questions > should return molding questions", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has vehicle parts questions > should return vehicle-parts", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: true,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.VEHICLE_PARTS);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("user has part questions > should return part-questions", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.PART_QUESTIONS);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should return quote, if not verified insurance", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
[fmgPageValues.QUOTE]: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.QUOTE);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should not return pages beyond quote even if prerequisites are met", async () => {
|
||||||
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
// Mock out the lazy load calls for all components.
|
||||||
|
mockLazyLoadComponentReturnValues({
|
||||||
|
[fmgPageValues.VEHICLE]: true,
|
||||||
|
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
||||||
|
[fmgPageValues.ESTIMATE]: true,
|
||||||
|
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
||||||
|
[fmgPageValues.VEHICLE_PARTS]: false,
|
||||||
|
[fmgPageValues.PART_QUESTIONS]: true,
|
||||||
|
[fmgPageValues.VIN_LOOKUP]: false,
|
||||||
|
[fmgPageValues.QUOTE]: true,
|
||||||
|
[fmgPageValues.SERVICE_LOCATION]: true,
|
||||||
|
[fmgPageValues.SCHEDULE]: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(result).toBe(fmgPageValues.QUOTE);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("user has capability questions and molding questions > should return capability questions", async () => {
|
describe("Explicit Routing", () => {
|
||||||
// Arrange
|
test("Returns the value passed in in nominal case", async () => {
|
||||||
const toRoute = {
|
// Arrange
|
||||||
query: {},
|
const toRoute = {
|
||||||
};
|
query: {
|
||||||
|
fmgPage: "testValue",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
// Act
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
// Assert
|
||||||
mockLazyLoadComponentReturnValues({
|
expect(result).toBe("testValue");
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.VEHICLE_PARTS]: false,
|
|
||||||
[fmgPageValues.PART_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.VIN_LOOKUP]: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
test("For verified insurance users, replace navigation to `vehicle` with `vehicle-damage`", async () => {
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
// Arrange
|
||||||
|
const toRoute = {
|
||||||
|
query: {
|
||||||
|
fmgPage: fmgPageValues.VEHICLE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
//Assert
|
store.commit(storeMutations.UPDATE_IS_VERIFIED_INSURANCE, true);
|
||||||
expect(result).toBe(fmgPageValues.CAPABILITY_QUESTIONS);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("user has molding questions and part questions > should return molding questions", async () => {
|
// Act
|
||||||
// Arrange
|
const result = await getPageToRouteExistingOrderTo(toRoute);
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
// Assert
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
expect(result).toBe(fmgPageValues.VEHICLE_DAMAGE);
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.VEHICLE_PARTS]: false,
|
|
||||||
[fmgPageValues.PART_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.VIN_LOOKUP]: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(fmgPageValues.MOLDING_QUESTIONS);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("user has vehicle parts questions > should return vehicle-parts", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.VEHICLE_PARTS]: true,
|
|
||||||
[fmgPageValues.PART_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.VIN_LOOKUP]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(fmgPageValues.VEHICLE_PARTS);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("user has part questions > should return part-questions", async () => {
|
|
||||||
// Arrange
|
|
||||||
const toRoute = {
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
|
||||||
|
|
||||||
// Mock out the lazy load calls for all components.
|
|
||||||
mockLazyLoadComponentReturnValues({
|
|
||||||
[fmgPageValues.VEHICLE]: true,
|
|
||||||
[fmgPageValues.VEHICLE_DAMAGE]: true,
|
|
||||||
[fmgPageValues.ESTIMATE]: true,
|
|
||||||
[fmgPageValues.CAPABILITY_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.MOLDING_QUESTIONS]: false,
|
|
||||||
[fmgPageValues.VEHICLE_PARTS]: false,
|
|
||||||
[fmgPageValues.PART_QUESTIONS]: true,
|
|
||||||
[fmgPageValues.VIN_LOOKUP]: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = await getPageToRouteExistingOrderTo(toRoute);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
expect(result).toBe(fmgPageValues.PART_QUESTIONS);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue