Add tests for lookupVinByImage action.

This commit is contained in:
Chloe Herd 2023-03-14 18:49:01 -04:00
parent e06be65e34
commit 8cd86fd6c2

View file

@ -403,6 +403,37 @@ describe("Actions", () => {
expect(response.data).toEqual({ carId: "C00000001" });
});
it("lookupVinByImage action, should return list of vins", async () => {
// Arrange
const context = state;
const dummyImage = {};
globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: [ "1C6JJTAG3NL134044" ] });
});
// Act
const response = await actions.lookupVinByImage(context, dummyImage);
// Assert
expect(response.data).toEqual([ "1C6JJTAG3NL134044" ]);
});
it("lookupVinByImage action, should reject if error in calling API", async () => {
// Arrange
const context = state;
const dummyImage = {};
globalMethods.callHttpClient.mockImplementation(() => {
return Promise.reject("An error occurred");
});
// Act
// Assert
await expect(actions.lookupVinByImage(context, dummyImage)).rejects.toEqual("An error occurred");
});
it("getVehicleMakes action, should return makes list", async () => {
// Arrange
const context = state;