From 7b2e581cd3fee384845e6be5a81bc7451893eadb Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 6 Apr 2023 20:04:17 +0530 Subject: [PATCH] fix: specs failing --- .../store/modules/specs/teams/actions.spec.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js b/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js index 8c11fb3a7..909f54e6f 100644 --- a/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js +++ b/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js @@ -17,7 +17,19 @@ jest.mock('axios'); describe('#actions', () => { describe('#get', () => { it('sends correct actions if API is success', async () => { - axios.get.mockResolvedValue({ data: teamsList[1] }); + const mockedGet = jest.fn(url => { + if (url === '/api/v1/teams') { + return Promise.resolve({ data: teamsList[1] }); + } + if (url === '/api/v1/accounts//cache_keys') { + return Promise.resolve({ data: { cache_keys: { teams: 0 } } }); + } + // Return default value or throw an error for unexpected requests + return Promise.reject(new Error('Unexpected request: ' + url)); + }); + + axios.get = mockedGet; + await actions.get({ commit }); expect(commit.mock.calls).toEqual([ [SET_TEAM_UI_FLAG, { isFetching: true }],