added unit test for auto selecting vehicle

This commit is contained in:
Katie Kroell 2023-06-12 11:04:12 -04:00
parent 0fecc0d989
commit 3da066f807

View file

@ -4,7 +4,6 @@ import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { useMainStore } from "@/store";
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import {vehicleSelectionOptions} from "@/constants/vehicle-selection-options";
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
// Mock fetchCmsContentForPage
@ -33,17 +32,6 @@ describe("policy-vehicles.vue", () => {
//Assert
expect(wrapper.vm.$router.navigate).toBeCalled();
});
test("Should navigate to CLICKED_BACK if backButtonAction is run", async () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
await wrapper.vm.backButtonAction();
//Assert
expect(wrapper.vm.$router.navigate).toBeCalled();
});
test("Selected vehicle VIN do match vehicles listed in our system (CarIDs) found then navigate forward to vehicle-damage page.", async () => {
//Arrange
const { wrapper } = setupMocks({});
@ -99,6 +87,16 @@ describe("policy-vehicles.vue", () => {
{}
);
});
test("first vehicle is auto-selected if only one vehicle on policy", async () => {
//Arrange
const { wrapper } = setupMocks({});
// Act
await wrapper.vm.$nextTick();
// Assert
expect(wrapper.vm.selectedVehicleVin).toBe("5NMS3CADXLH233004");
});
});
function setupMocks({
@ -109,15 +107,15 @@ function setupMocks({
useMainStore().applicationUser = {
pageData: {
"policy-vehicles":
[
{
vehicleMake: "Hyundai",
vehicleModel: "Santa Fe",
vehicleStyle: "4 door utility",
vehicleYear: 2020,
vin: "5NMS3CADXLH233004",
},
],
[
{
vehicleMake: "Hyundai",
vehicleModel: "Santa Fe",
vehicleStyle: "4 door utility",
vehicleYear: 2020,
vin: "5NMS3CADXLH233004",
},
],
}
};
useMainStore().lookupVehicleByVin = jest.fn().mockImplementation(() => {