Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/components/UI/Ramp/Deposit/hooks/useDepositUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('useDepositUser', () => {
expect(mockFetchUserDetails).toHaveBeenCalled();
});

it('logs out and throws on 401 error', async () => {
it('logs out but does not throw on 401 error', async () => {
const error401 = Object.assign(new Error('Unauthorized'), {
status: 401,
}) as AxiosError;
Expand All @@ -284,13 +284,11 @@ describe('useDepositUser', () => {
);

mockFetchUserDetails.mockRejectedValue(error401);
setupMockSdkMethod({ data: mockUserDetails });
setupMockSdkMethod();

const { result } = renderHook(() => useDepositUser());

await expect(result.current.fetchUserDetails()).rejects.toThrow(
'Unauthorized',
);
await result.current.fetchUserDetails();

expect(mockLogoutFromProvider).toHaveBeenCalledWith(false);
});
Expand Down
3 changes: 2 additions & 1 deletion app/components/UI/Ramp/Deposit/hooks/useDepositUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export function useDepositUser() {
if ((error as AxiosError).status === 401) {
Logger.log('useDepositUser: 401 error, clearing authentication');
await logoutFromProvider(false);
} else {
throw error;
}
throw error;
}
}, [fetchUserDetails, logoutFromProvider]);

Expand Down
Loading