should call invalidate when logout is called

master
Tudor Stanciu 2023-02-12 01:06:58 +02:00
parent f18f31a63e
commit c7a1a465ff
1 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { renderHook, act } from "@testing-library/react-hooks";
import { TuitioClient } from "@flare/tuitio-client";
import { TuitioClient, invalidate } from "@flare/tuitio-client";
import { useTuitioClient } from "../../src/hooks";
jest.mock("@flare/tuitio-client", () => ({
@ -81,4 +81,20 @@ describe("useTuitioClient", () => {
"user"
);
});
it("should call invalidate when logout is called", () => {
const { result } = renderHook(() =>
useTuitioClient({
onLoginSuccess: jest.fn(),
onLoginFailed: jest.fn(),
onLoginError: jest.fn()
})
);
act(() => {
result.current.logout();
});
expect(invalidate).toHaveBeenCalled();
});
});