updates for unit tests and code coverage
This commit is contained in:
parent
8930cc8681
commit
d7908620a7
4 changed files with 73 additions and 23 deletions
|
|
@ -34,7 +34,8 @@ module.exports = {
|
|||
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
||||
coverageThreshold: {
|
||||
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
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const endpoints = {
|
|||
LoadOrder: {
|
||||
url: "/order/api/v1/order/load",
|
||||
method: "POST",
|
||||
}
|
||||
},
|
||||
ValidateZip: {
|
||||
url: "/location/api/v1/location/zip",
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -6,27 +6,29 @@ import createPersistedState from "vuex-persistedstate";
|
|||
import globalMethods from "@/global-methods";
|
||||
|
||||
// Export State
|
||||
export const state = {
|
||||
order: {
|
||||
vehicle: {
|
||||
year: null,
|
||||
make: null,
|
||||
model: null,
|
||||
style: null,
|
||||
carId: null,
|
||||
category: null,
|
||||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
imageColor: null,
|
||||
vin: null,
|
||||
registration: {
|
||||
licensePlate: null,
|
||||
address: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
const getDefaultState = () => {
|
||||
return {
|
||||
order: {
|
||||
vehicle: {
|
||||
year: null,
|
||||
make: null,
|
||||
model: null,
|
||||
style: null,
|
||||
carId: null,
|
||||
category: null,
|
||||
vin: null,
|
||||
imageUrl: null,
|
||||
imageVifNumber: null,
|
||||
imageColor: null,
|
||||
registration: {
|
||||
licensePlate: null,
|
||||
address: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
firstName: null,
|
||||
lastName: null,
|
||||
},
|
||||
},
|
||||
serviceLocation: {
|
||||
zip: null,
|
||||
|
|
|
|||
|
|
@ -283,6 +283,22 @@ describe("Actions", () => {
|
|||
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 () => {
|
||||
|
||||
// Arrange
|
||||
|
|
@ -368,6 +384,22 @@ describe("Actions", () => {
|
|||
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 () => {
|
||||
|
||||
// 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 () => {
|
||||
|
||||
// Arrange
|
||||
|
|
|
|||
Loading…
Reference in a new issue