From 591f512fdeb1ffd9aab1afd1c4cd3c9a45f68c23 Mon Sep 17 00:00:00 2001 From: Sneha Date: Wed, 2 Aug 2023 16:52:48 +0530 Subject: [PATCH] update index.js --- src/store/index.js | 4 ++++ src/store/store.spec.js | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index fe05a4a53..41ca166c1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1620,6 +1620,10 @@ export const actions = { }, saveVehicle(context, { year, make, model, style }) { + context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); + if (context.state.order.vehicle.year !== year) { context.commit(storeMutations.UPDATE_YEAR, year); } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 1081d383c..08aa406c9 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1718,8 +1718,10 @@ describe("Actions", () => { }; const commit = jest.fn(); + const dispatch = jest.fn(); context.commit = commit; + context.dispatch = dispatch; //Act const payload = { @@ -1731,6 +1733,14 @@ describe("Actions", () => { actions.saveVehicle(context, payload); //Assert + expect(dispatch).toHaveBeenNthCalledWith( + 1, + storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES + ); + expect(dispatch).toHaveBeenNthCalledWith( + 2, + storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES + ); if (context.state.order.vehicle.year !== payload.year) { expect(commit).toBeCalledWith(storeMutations.UPDATE_YEAR, payload.year); }