diff --git a/src/services/defaultOrganization/useUpdateDefaultOrganization.spec.tsx b/src/services/defaultOrganization/useUpdateDefaultOrganization.spec.tsx index 999fd359a8..21b0d0a317 100644 --- a/src/services/defaultOrganization/useUpdateDefaultOrganization.spec.tsx +++ b/src/services/defaultOrganization/useUpdateDefaultOrganization.spec.tsx @@ -60,12 +60,17 @@ describe('useUpdateDefaultOrganization', () => { wrapper, }) result.current.mutate({ username: 'codecov' }) + const invalidateQueries = jest.spyOn(queryClient, 'invalidateQueries') await waitFor(() => expect(result.current.isSuccess).toBeTruthy()) const username = result.current.data.data.updateDefaultOrganization.username await waitFor(() => expect(username).toBe('Gilmore')) + + expect(invalidateQueries).toHaveBeenCalledTimes(2) + expect(invalidateQueries).toHaveBeenNthCalledWith(1, ['DetailOwner']) + expect(invalidateQueries).toHaveBeenNthCalledWith(2, ['currentUser']) }) }) }) diff --git a/src/services/defaultOrganization/useUpdateDefaultOrganization.ts b/src/services/defaultOrganization/useUpdateDefaultOrganization.ts index aca4d8d78e..803b1f9098 100644 --- a/src/services/defaultOrganization/useUpdateDefaultOrganization.ts +++ b/src/services/defaultOrganization/useUpdateDefaultOrganization.ts @@ -41,6 +41,7 @@ export function useUpdateDefaultOrganization() { ) } else { queryClient.invalidateQueries(['DetailOwner']) + queryClient.invalidateQueries(['currentUser']) } }, onError: (e: any) => {