Added additional unit tests and excluded from coverage those components still in development
This commit is contained in:
parent
27d44aae7a
commit
4257828465
5 changed files with 98 additions and 154 deletions
|
|
@ -19,6 +19,8 @@ module.exports = {
|
||||||
"!src/layouts/vin-lookup/**/*.vue", //Temporary for Quote page testing
|
"!src/layouts/vin-lookup/**/*.vue", //Temporary for Quote page testing
|
||||||
"!src/common-components/funnel-header/menu-modal/**/*.vue",
|
"!src/common-components/funnel-header/menu-modal/**/*.vue",
|
||||||
"!src/layouts/schedule/*.vue", // Temp test exclusion while in development
|
"!src/layouts/schedule/*.vue", // Temp test exclusion while in development
|
||||||
|
"!src/layouts/schedule/helpers/schedule-helper.js", // Temp test exclusion while in development
|
||||||
|
"!src/layouts/review/*.vue", // Temp test exclusion while in development
|
||||||
// END
|
// END
|
||||||
], // ! means exclude from coverage.
|
], // ! means exclude from coverage.
|
||||||
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,18 @@ describe("object-cloning-helper.js", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(result).toStrictEqual(expected);
|
expect(result).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should return a copy of the array", async () => {
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
const array = [9, 8, 7, 6, 5, 4, 3, 2, 1];
|
||||||
|
|
||||||
|
const expected = [9, 8, 7, 6, 5, 4, 3, 2, 1];;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = deepClone(array);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toStrictEqual(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { getPricedMobileFeePart } from "./service-location-helper";
|
import { getPricedMobileFeePart, getServiceabilityDetails } from "./service-location-helper";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
||||||
const mockStoreActionGetMobileFeePart = storeActions.GET_MOBILE_FEE_PART;
|
const mockStoreActionGetMobileFeePart = storeActions.GET_MOBILE_FEE_PART;
|
||||||
const mockStoreActionPriceOrderItemsAndSaveServerData =
|
const mockStoreActionPriceOrderItemsAndSaveServerData =
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA;
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA;
|
||||||
|
const mockStoreActionGetServiceabilityDetails =
|
||||||
|
storeActions.GET_SERVICEABILITY_DETAILS;
|
||||||
|
|
||||||
jest.mock("@/mixins/base-mixin.js", () => ({
|
jest.mock("@/mixins/base-mixin.js", () => ({
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -40,56 +42,90 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actionName === mockStoreActionGetServiceabilityDetails) {
|
||||||
|
return Promise.resolve(
|
||||||
|
{
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
|
isRecalibrationServiceableInshop: true,
|
||||||
|
isGlassServiceableMobile: true,
|
||||||
|
isRecalibrationServiceableMobile: true
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("service-location-helper.js", () => {
|
describe("service-location-helper.js", () => {
|
||||||
it("Should return null if no service zip code is passed in", async () => {
|
describe("getPricedMobileFeePart", () => {
|
||||||
// Arrange
|
it("Should return null if no service zip code is passed in", async () => {
|
||||||
const serviceZipCode = null;
|
// Arrange
|
||||||
const damageType = "Replace";
|
const serviceZipCode = null;
|
||||||
const parentAccountNumber = 167132;
|
const damageType = "Replace";
|
||||||
const billToAccountNumber = 1234;
|
const parentAccountNumber = 167132;
|
||||||
const expected = null;
|
const billToAccountNumber = 1234;
|
||||||
|
const expected = null;
|
||||||
// Act
|
|
||||||
const result = await getPricedMobileFeePart(
|
// Act
|
||||||
serviceZipCode,
|
const result = await getPricedMobileFeePart(
|
||||||
damageType,
|
serviceZipCode,
|
||||||
parentAccountNumber,
|
damageType,
|
||||||
billToAccountNumber
|
parentAccountNumber,
|
||||||
);
|
billToAccountNumber
|
||||||
|
);
|
||||||
// Assert
|
|
||||||
expect(result).toEqual(expected);
|
// Assert
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return the priced mobile fee part", async () => {
|
||||||
|
// Arrange
|
||||||
|
const serviceZipCode = "43235";
|
||||||
|
const damageType = "Replace";
|
||||||
|
const parentAccountNumber = 167132;
|
||||||
|
const billToAccountNumber = 1234;
|
||||||
|
|
||||||
|
const expected = {
|
||||||
|
partNumber: "MOBILE FEE",
|
||||||
|
description: "MOBILE FEE",
|
||||||
|
partType: "FEE",
|
||||||
|
laborAmount: 49.99,
|
||||||
|
sellingPrice: 0,
|
||||||
|
kitPrice: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const result = await getPricedMobileFeePart(
|
||||||
|
serviceZipCode,
|
||||||
|
damageType,
|
||||||
|
parentAccountNumber,
|
||||||
|
billToAccountNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toEqual(expected);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return the priced mobile fee part", async () => {
|
describe("getServiceabilityDetails", () => {
|
||||||
// Arrange
|
it("Should return the serviceability details", async () => {
|
||||||
const serviceZipCode = "43235";
|
// Arrange
|
||||||
const damageType = "Replace";
|
const serviceZipCode = "43235";
|
||||||
const parentAccountNumber = 167132;
|
|
||||||
const billToAccountNumber = 1234;
|
const expected = {
|
||||||
|
isGlassServiceableInshop: true,
|
||||||
const expected = {
|
isRecalibrationServiceableInshop: true,
|
||||||
partNumber: "MOBILE FEE",
|
isGlassServiceableMobile: true,
|
||||||
description: "MOBILE FEE",
|
isRecalibrationServiceableMobile: true
|
||||||
partType: "FEE",
|
};
|
||||||
laborAmount: 49.99,
|
|
||||||
sellingPrice: 0,
|
// Act
|
||||||
kitPrice: 0,
|
const result = await getServiceabilityDetails(serviceZipCode);
|
||||||
};
|
|
||||||
|
// Assert
|
||||||
// Act
|
expect(result).toEqual(expected);
|
||||||
const result = await getPricedMobileFeePart(
|
});
|
||||||
serviceZipCode,
|
|
||||||
damageType,
|
|
||||||
parentAccountNumber,
|
|
||||||
billToAccountNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toEqual(expected);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -505,36 +505,6 @@ describe("service-location.vue", () => {
|
||||||
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("resets appointment type selection when service zip code is updated by mobile location modal when Mobile is not selected", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
await wrapper.setData({
|
|
||||||
selectedAppointmentType: "Dropoff",
|
|
||||||
});
|
|
||||||
|
|
||||||
const mobileLocationQuestionsComponent = wrapper.findComponent({
|
|
||||||
ref: "mobileLocationQuestions",
|
|
||||||
});
|
|
||||||
mobileLocationQuestionsComponent.resetComponent = jest.fn();
|
|
||||||
|
|
||||||
const serviceZipCodeComponent = wrapper.findComponent({
|
|
||||||
ref: "serviceZipCodeQuestion",
|
|
||||||
});
|
|
||||||
serviceZipCodeComponent.resetMobileFeePart = jest.fn();
|
|
||||||
|
|
||||||
const newServiceZipCodeQuestion = {
|
|
||||||
zipCode: "61606",
|
|
||||||
state: "IL",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
serviceZipCodeComponent.vm.$emit("update:modelValue", newServiceZipCodeQuestion);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.selectedAppointmentType).toStrictEqual(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", async () => {
|
test("does not reset appointment type selection when service zip code is updated by mobile location modal when Mobile is selected", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -570,6 +540,7 @@ describe("service-location.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.selectedAppointmentType).toStrictEqual("Mobile");
|
expect(wrapper.vm.selectedAppointmentType).toStrictEqual("Mobile");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("serviceability logic", () => {
|
describe("serviceability logic", () => {
|
||||||
|
|
|
||||||
|
|
@ -487,85 +487,6 @@ describe("shop-question.vue", () => {
|
||||||
expect(wrapper.vm.answers.length).toEqual(3);
|
expect(wrapper.vm.answers.length).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it.only("Should reload the shops when the service zip code changes", async () => {
|
|
||||||
// // Arrange
|
|
||||||
// const { wrapper } = setupMocks({
|
|
||||||
// mixins: [mockMixin],
|
|
||||||
// props: {
|
|
||||||
// modelValue: {
|
|
||||||
// address: {
|
|
||||||
// city: "POWELL",
|
|
||||||
// country: "US",
|
|
||||||
// state: "OH",
|
|
||||||
// streetAddress: "3938 POWELL RD",
|
|
||||||
// zipCode: "43065",
|
|
||||||
// },
|
|
||||||
// distanceInMiles: 16.2690495685233,
|
|
||||||
// providerNumber: "003341",
|
|
||||||
// },
|
|
||||||
// serviceZipCode: "43081",
|
|
||||||
// selectedAppointmentType: "Dropoff",
|
|
||||||
// cmsWidgetName: cmsWidgetName,
|
|
||||||
// isDisplayed: true,
|
|
||||||
// },
|
|
||||||
// mountOptions: {
|
|
||||||
// attachTo: document.body,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// wrapper.vm.$options.methods.loadInitialData = jest.fn().mockImplementation(() => {
|
|
||||||
// return new Promise((resolve) => {
|
|
||||||
// resolve(mockNewShopList);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Act
|
|
||||||
// wrapper.vm.initializeComponent(shopQuestionInitialData);
|
|
||||||
|
|
||||||
// //await wrapper.vm.$options.watch.serviceZipCode.handler.call(wrapper.vm, "43054");
|
|
||||||
|
|
||||||
// // Assert
|
|
||||||
// expect(wrapper.vm.shopProviders.length).toEqual(3);
|
|
||||||
// expect(wrapper.vm.shopProviders).toEqual(mockNewShopList.shopProviders);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it("Should clear the existing answers when the service zip code changes", async () => {
|
|
||||||
// // Arrange
|
|
||||||
// const { wrapper } = setupMocks({
|
|
||||||
// mixins: [mockMixin],
|
|
||||||
// props: {
|
|
||||||
// modelValue: {
|
|
||||||
// address: {
|
|
||||||
// city: "POWELL",
|
|
||||||
// country: "US",
|
|
||||||
// state: "OH",
|
|
||||||
// streetAddress: "3938 POWELL RD",
|
|
||||||
// zipCode: "43065",
|
|
||||||
// },
|
|
||||||
// distanceInMiles: 16.2690495685233,
|
|
||||||
// providerNumber: "003341",
|
|
||||||
// },
|
|
||||||
// serviceZipCode: "43081",
|
|
||||||
// selectedAppointmentType: "Dropoff",
|
|
||||||
// cmsWidgetName: cmsWidgetName,
|
|
||||||
// },
|
|
||||||
// mountOptions: {
|
|
||||||
// attachTo: document.body,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// //Act
|
|
||||||
// wrapper.vm.initializeComponent(shopQuestionInitialData);
|
|
||||||
|
|
||||||
// wrapper.setProps({
|
|
||||||
// selectedAppointmentType: "Inshop",
|
|
||||||
// });
|
|
||||||
|
|
||||||
// await wrapper.vm.$nextTick();
|
|
||||||
|
|
||||||
// // Assert
|
|
||||||
// expect(wrapper.vm.answers.length).toEqual(3);
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) {
|
function setupMocks({ mountOptions, mixins, props, isShallowMount = true }) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue