From 9112046093d43713da6544a8bc08f0f0175a5c99 Mon Sep 17 00:00:00 2001 From: Sneha Date: Thu, 23 Feb 2023 12:27:43 +0530 Subject: [PATCH] Update capability-questions.spec.js --- .../capability-questions.spec.js | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/layouts/capability-questions/capability-questions.spec.js b/src/layouts/capability-questions/capability-questions.spec.js index 42dcff14..0e488e9e 100644 --- a/src/layouts/capability-questions/capability-questions.spec.js +++ b/src/layouts/capability-questions/capability-questions.spec.js @@ -144,10 +144,12 @@ describe("capabilityQuestions.vue", () => { }); describe("watch on selectedAnswers should be set up...", () => { - test("Should trigger handleCompletedQuestionChainAnswers if watched data changes", async () => { + test("Should trigger handleAnswerUpdates if watched data changes", async () => { // Arrange + useMainStore().pageData = baseStoreGettersPageData; + useMainStore().damage = baseStoreGettersDamage; const { wrapper } = setupMocks({}); - const spy = jest.spyOn(wrapper.vm, "handleCompletedQuestionChainAnswers"); + const spy = jest.spyOn(wrapper.vm, "handleAnswerUpdates"); // Act wrapper.setData({ @@ -257,6 +259,44 @@ describe("capabilityQuestions.vue", () => { expect(wrapper.vm.saveCapabilityQuestionAnswers).toHaveBeenCalled; wrapper.unmount(); }); + test("Should call GET_PARTS_OR_QUESTIONS API", async () => { + // Arrange + const { wrapper } = setupMocks({}); + + wrapper.vm.questionsData = [ + { + glassLocation: "Windshield", + glassName: "Single", + answerData: { + answerResult: "FW04848", + answeredQuestions: [], + }, + questions: [], + parts: [ + { + childPartQuestions: [], + }, + ], + }, + ]; + useMainStore().getPartsOrQuestions = jest.fn(() => { + return { + data: { + partsOrQuestions: [], + }, + }; + }); + + // Act + wrapper.vm.forwardButtonAction(); + + await nextTick(); + + //Assert + expect(wrapper.vm.getPartsOrQuestions).toHaveBeenCalled; + + wrapper.unmount(); + }); test("Should trigger navigateForward", async () => { // Arrange