From 7594056c940a2bf1ea0ff335272661962eb03f03 Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Thu, 25 Jul 2024 08:23:28 -0500 Subject: [PATCH] SSR-1431 Update Unit Tests --- src/layouts/vin-lookup/vin-lookup.spec.js | 47 ++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index cd8470be..2ac22591 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -24,7 +24,17 @@ const lookupVehicleByVin = { methodName: 'lookupVehicleByVin', mockResponse: { data: { - carId: mockCarId + carId: mockCarId, + canSafeliteService: true + } + } +}; +const lookupVehicleByVinCannotService = { + methodName: 'lookupVehicleByVin', + mockResponse: { + data: { + carId: mockCarId, + canSafeliteService: false } } }; @@ -484,6 +494,41 @@ describe('vin-lookup.vue', () => { ); }); }); + test('Bailout if entered vin cannot be serviced', async () => { + const user = userEvent.setup(); + mountOptions.global.stubs.vinQuestion = false; + + mountOptions.data = () => ({ + vinWithNonMatchingCarId: false, + isCarIdDifferentFromTheStore: false, + vin: mockValidVin + }); + + getPartsOrQuestions.mockResponse = vehicleWithNoAdditionalPartsOrQuestionsMockResponse; + + jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName) + .mockResolvedValue(lookupVehicleByVinCannotService.mockResponse); + jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName) + .mockResolvedValue(getPartsOrQuestions.mockResponse); + + const { container } = render(VinLookupComponent, mountOptions); + + const vinInput = container.querySelector(vinInputSelector); + await user.type(vinInput, mockValidVin); + + const continueButton = container.querySelector(continueButtonQuerySelector); + await user.click(continueButton); + + await flushPromises(); + await waitFor(() => { + expect(mockRouter.navigate).toHaveBeenCalledTimes(1); + expect(mockRouter.navigate) + .toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + mockRoute + ); + }); + }); // eslint-disable-next-line max-len test('Policy Vehicle with invalid vin corrected. Click "Continue", execute navigate with navigationScenario.CORRECTED_VIN_FROM_POLICY_VEHICLE', async () => {