import * as APIUtils from '../store/utils/api'; import Auth from './auth'; vi.spyOn(APIUtils, 'clearCookiesOnLogout').mockImplementation(() => {}); vi.spyOn(APIUtils, 'deleteIndexedDBOnLogout').mockResolvedValue(); describe('Auth.logout', () => { it('clears browser credentials even when the server rejects logout', async () => { globalThis.axios = { delete: vi.fn().mockRejectedValue({ response: { status: 401 } }), }; await expect(Auth.logout()).rejects.toEqual({ response: { status: 401 } }); expect(APIUtils.deleteIndexedDBOnLogout).toHaveBeenCalledOnce(); expect(APIUtils.clearCookiesOnLogout).toHaveBeenCalledOnce(); }); });