From 54c760830f77da8ddfdc778fcc1e674250f51668 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Thu, 12 Oct 2023 15:40:36 -0400 Subject: [PATCH] unit test for nav scenario --- .../policy-vehicles/policy-vehicles.spec.js | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index 14518679..0ea0770f 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -117,7 +117,8 @@ describe('policy-vehicles.vue', () => { vin, noCoverage: true, deductible: 0, - repairWaived: false + repairWaived: false, + endorsements: [] }; // Act @@ -135,6 +136,57 @@ describe('policy-vehicles.vue', () => { } ); + test( + // eslint-disable-next-line max-len + 'Selected VIN matches vehicle listed in system and policy vehicle has endorsements => update vehicle and navigate forward with CLICKED_FORWARD_WITH_ENDORSEMENTS scenario.', + async () => { + // Arrange + const { wrapper } = setupMocks({}); + + const vin = getRandomString(17, 17); + const endorsements = [getRandomString(10, 20)]; + await wrapper.setData({ + selectedVehicleVin: vin, + policyVehicles: [ + { + vin, + endorsements + } + ], + bailout: false + }); + + const year = getRandomInt(1998, 2023); + const lookupVehicleResponse = { + data: { + year + } + }; + const store = useMainStore(); + store.lookupVehicleByVin.mockReturnValue(Promise.resolve(lookupVehicleResponse)); + + const expectedInput = { + year, + vin, + noCoverage: true, + deductible: 0, + repairWaived: false, + endorsements + }; + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.bailout).toBeFalsy(); + expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput); + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS, + undefined + ); + } + ); + test( 'Error in lookupVehicleByVin call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario.', async () => {