should call invalidate when logout is called
parent
f18f31a63e
commit
c7a1a465ff
|
@ -1,5 +1,5 @@
|
||||||
import { renderHook, act } from "@testing-library/react-hooks";
|
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";
|
import { useTuitioClient } from "../../src/hooks";
|
||||||
|
|
||||||
jest.mock("@flare/tuitio-client", () => ({
|
jest.mock("@flare/tuitio-client", () => ({
|
||||||
|
@ -81,4 +81,20 @@ describe("useTuitioClient", () => {
|
||||||
"user"
|
"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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue