From c7a1a465ffe8d77698fcab3aefb67137443cbc6e Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 12 Feb 2023 01:06:58 +0200 Subject: [PATCH] should call invalidate when logout is called --- tests/hooks/useTuitioClient.test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/hooks/useTuitioClient.test.ts b/tests/hooks/useTuitioClient.test.ts index fc2181d..c91c7b0 100644 --- a/tests/hooks/useTuitioClient.test.ts +++ b/tests/hooks/useTuitioClient.test.ts @@ -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(); + }); });