added unit test for auto selecting vehicle
This commit is contained in:
parent
0fecc0d989
commit
3da066f807
1 changed files with 19 additions and 21 deletions
|
|
@ -4,7 +4,6 @@ import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { useMainStore } from "@/store";
|
import { useMainStore } from "@/store";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import {vehicleSelectionOptions} from "@/constants/vehicle-selection-options";
|
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
|
|
||||||
// Mock fetchCmsContentForPage
|
// Mock fetchCmsContentForPage
|
||||||
|
|
@ -33,17 +32,6 @@ describe("policy-vehicles.vue", () => {
|
||||||
//Assert
|
//Assert
|
||||||
expect(wrapper.vm.$router.navigate).toBeCalled();
|
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 () => {
|
test("Selected vehicle VIN do match vehicles listed in our system (CarIDs) found then navigate forward to vehicle-damage page.", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
const { wrapper } = setupMocks({});
|
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({
|
function setupMocks({
|
||||||
|
|
@ -109,15 +107,15 @@ function setupMocks({
|
||||||
useMainStore().applicationUser = {
|
useMainStore().applicationUser = {
|
||||||
pageData: {
|
pageData: {
|
||||||
"policy-vehicles":
|
"policy-vehicles":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
vehicleMake: "Hyundai",
|
vehicleMake: "Hyundai",
|
||||||
vehicleModel: "Santa Fe",
|
vehicleModel: "Santa Fe",
|
||||||
vehicleStyle: "4 door utility",
|
vehicleStyle: "4 door utility",
|
||||||
vehicleYear: 2020,
|
vehicleYear: 2020,
|
||||||
vin: "5NMS3CADXLH233004",
|
vin: "5NMS3CADXLH233004",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
useMainStore().lookupVehicleByVin = jest.fn().mockImplementation(() => {
|
useMainStore().lookupVehicleByVin = jest.fn().mockImplementation(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue