should call onLoginError with error if authentication fails
parent
c7a1a465ff
commit
627e2105f8
|
@ -82,6 +82,25 @@ describe("useTuitioClient", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("should call onLoginError with error if authentication fails", async () => {
|
||||
(TuitioClient as jest.Mocked<any>).mockImplementation(() => ({
|
||||
authenticate: jest.fn().mockRejectedValue(new Error("Login failed"))
|
||||
}));
|
||||
|
||||
const onLoginError = jest.fn();
|
||||
const { result } = renderHook(() =>
|
||||
useTuitioClient({ onLoginSuccess: jest.fn(), onLoginFailed: jest.fn(), onLoginError })
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
try {
|
||||
await result.current.login("user", "password");
|
||||
} catch (error) {
|
||||
expect(onLoginError).toHaveBeenCalledWith(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should call invalidate when logout is called", () => {
|
||||
const { result } = renderHook(() =>
|
||||
useTuitioClient({
|
||||
|
|
Loading…
Reference in New Issue