From b770d9c0789f291df4591309cf53b0684ce23a69 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Mon, 5 Dec 2022 14:51:22 -0500 Subject: [PATCH] commit --- src/layouts/vehicle-parts/vehicle-parts.spec.js | 14 ++++++++++---- src/mixins/vehicle-questions-mixin.js | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 4b67fe64..ed6732be 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -61,7 +61,7 @@ const basePartResponse = { }; describe("vehicle-parts.vue", () => { - test("Set cms content called on load", async (done) => { + test("Set cms content called on load", async () => { //Arrange useMainStore().pageData = jest.fn(); useMainStore().pageData.mockReturnValue(basePartResponse); @@ -95,7 +95,6 @@ describe("vehicle-parts.vue", () => { //Assert apiPromise.finally(() => { expect(wrapper.vm.setCmsContent).toHaveBeenCalled(); - done(); }); }); @@ -104,6 +103,7 @@ describe("vehicle-parts.vue", () => { useMainStore().pageData = jest.fn(); useMainStore().pageData.mockReturnValue(basePartResponse); useMainStore().lineItems = { glassParts: null }; + useMainStore().damage.isRepair = false; const { wrapper } = setupMocks({ mountOptionsMockData: { @@ -202,7 +202,7 @@ describe("vehicle-parts.vue", () => { //Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, + navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, wrapper.vm.$route ); }); @@ -234,7 +234,7 @@ describe("vehicle-parts.vue", () => { //Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( - navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, + navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS, wrapper.vm.$route ); }); @@ -371,6 +371,7 @@ describe("vehicle-parts.vue", () => { (c) => c(wrapper.vm) ); + await wrapper.vm.forwardButtonAction(); //Assert @@ -401,10 +402,15 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {} }, }; + const store = useMainStore(); + let actionResult = []; + store.getCapabilityQuestions.mockImplementation(() => Promise.resolve({data: actionResult,})); + const apiPromise = Promise.resolve(apiResponses); settleAllPromises.mockImplementation(() => apiPromise); fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); + const mountOptions = getMountOptions(mountOptionsMockData); const wrapper = shallowMount(vehicleParts, mountOptions); diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 9e482eea..8a67d9b4 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -405,7 +405,7 @@ export default { // mimic part-questions page data for consistency for (let partOrQuestion of partsOrQuestions) { if (this.hasCapabilityQuestions([partOrQuestion])) { - let capabilityQuestionsForGlassLocation = (await this.mainStore.getCapabilityQuestions(this.mainStore.vehicle.carId, partOrQuestion.parts[0].partNumber)).data; + let capabilityQuestionsForGlassLocation = (await useMainStore().getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)).data; capabilityQuestionsForGlassLocation.forEach((question) => { question.answers = question.answers.map((answer) => { @@ -432,7 +432,7 @@ export default { const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); // save to store lineItems.glassParts - self.mainStore.updateGlassParts(collectedGlassParts); + useMainStore().updateGlassParts(collectedGlassParts); self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,self.$route); }