From ee08bed3eaac9d02b9969046af80783962a0d272 Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Tue, 23 Apr 2024 14:43:27 -0400 Subject: [PATCH] completed unit test --- src/layouts/vin-lookup/vin-lookup.spec.js | 17 +++++++++-------- src/layouts/vin-lookup/vin-lookup.vue | 11 ++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index cf76f334..cd8470be 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -122,14 +122,7 @@ const vehicleWithNoAdditionalPartsOrQuestionsMockResponse = { }; const partsOrQuestionsErrorMockResponse = { - data: { - partsOrQuestions: [ - { - parts: null - } - ], - partQuestions: null - } + error: 'Error getting parts' }; jest.mock('bootstrap', () => ({ @@ -533,6 +526,14 @@ describe('vin-lookup.vue', () => { async () => { const user = userEvent.setup(); mountOptions.global.stubs.vinQuestion = false; + + mountOptions.data = () => ({ + vinWithNonMatchingCarId: false, + isCarIdDifferentFromTheStore: false, + vin: mockValidVin, + hasBailedOut: true + }); + getPartsOrQuestions.mockResponse = partsOrQuestionsErrorMockResponse; jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 78c594f8..9bbf2c59 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -151,6 +151,9 @@ export default { carIdIsValid() { return this.hasValidCarId(); }, + hasBailedOut() { + return false; + } }, watch: { vin() { @@ -274,14 +277,12 @@ export default { return null; } - let hasBailedOut = false; const partsOrQuestionsResponse = await this.getPartsOrQuestions(); if (partsOrQuestionsResponse.error) { - this.mainStore.setBailout( - bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data)); + this.mainStore.setBailout(bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data)); window.console.error('Error on retrieving PartsOrQuestions'); this.$refs.siteFooter.removeLoader(); - hasBailedOut = true; + this.hasBailedOut = true; this.$router.navigate( this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, this.$route @@ -289,7 +290,7 @@ export default { } // Comes from vehicleQuestionsMixin.navigateForward() - if (!hasBailedOut) { + if (!this.hasBailedOut) { await this.navigateForward( partsOrQuestionsResponse.data.partsOrQuestions, this