updates for unit tests and code coverage

This commit is contained in:
Max 2022-04-05 14:08:21 -04:00
parent 8930cc8681
commit d7908620a7
4 changed files with 73 additions and 23 deletions

View file

@ -34,7 +34,8 @@ module.exports = {
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
coverageThreshold: { coverageThreshold: {
global: { global: {
statements: 89, statements: 87,
// Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90
}, },
}, },
}; };

View file

@ -58,7 +58,7 @@ const endpoints = {
LoadOrder: { LoadOrder: {
url: "/order/api/v1/order/load", url: "/order/api/v1/order/load",
method: "POST", method: "POST",
} },
ValidateZip: { ValidateZip: {
url: "/location/api/v1/location/zip", url: "/location/api/v1/location/zip",
method: "GET", method: "GET",

View file

@ -6,27 +6,29 @@ import createPersistedState from "vuex-persistedstate";
import globalMethods from "@/global-methods"; import globalMethods from "@/global-methods";
// Export State // Export State
export const state = { const getDefaultState = () => {
order: { return {
vehicle: { order: {
year: null, vehicle: {
make: null, year: null,
model: null, make: null,
style: null, model: null,
carId: null, style: null,
category: null, carId: null,
imageUrl: null, category: null,
imageVifNumber: null, vin: null,
imageColor: null, imageUrl: null,
vin: null, imageVifNumber: null,
registration: { imageColor: null,
licensePlate: null, registration: {
address: null, licensePlate: null,
city: null, address: null,
state: null, city: null,
zipCode: null, state: null,
firstName: null, zipCode: null,
lastName: null, firstName: null,
lastName: null,
},
}, },
serviceLocation: { serviceLocation: {
zip: null, zip: null,

View file

@ -283,6 +283,22 @@ describe("Actions", () => {
expect(response.data).toEqual({ carId: "C00000001" }); expect(response.data).toEqual({ carId: "C00000001" });
}); });
it("lookupVinByPlate action, should return car data", async () => {
// Arrange
const context = state;
// Act
globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: { carId: "C00000001" } });
});
// Assert
const response = await actions.lookupVinByPlate(context, "12345678901234567")
expect(response.data).toEqual({ carId: "C00000001" });
});
it("getVehicleMakes action, should return makes list", async () => { it("getVehicleMakes action, should return makes list", async () => {
// Arrange // Arrange
@ -368,6 +384,22 @@ describe("Actions", () => {
expect(response.data).toEqual(["Windshield", "DriversFrontDoor"]); expect(response.data).toEqual(["Windshield", "DriversFrontDoor"]);
}); });
it("validateZip action", async () => {
// Arrange
const context = state;
// Act
globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: "43201" });
});
const response = await actions.validateZip(context, "C00000000")
// Assert
expect(response.data).toEqual("43201");
});
it("resetVehicleAndDependencies action", async () => { it("resetVehicleAndDependencies action", async () => {
// Arrange // Arrange
@ -432,6 +464,21 @@ describe("Actions", () => {
}); });
it("resetState action", async () => {
// Arrange
const context = state;
const commit = jest.fn();
context.commit = commit;
// Act
await actions.resetState(context)
expect(commit).toBeCalledWith(storeMutations.RESET_STATE);
});
it("getRouteInfo action, returns route info", async () => { it("getRouteInfo action, returns route info", async () => {
// Arrange // Arrange