mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-26 21:02:31 +03:00
7a2450eaf4
* feat: add empty access list message * feat: set default role to viewer * feat: reset user invitation form after submit * feat: add removing access indicator * feat: add brain name on invitation page * feat: display brain name on chat page * feat: clear localStorage on logout
41 lines
934 B
TypeScript
41 lines
934 B
TypeScript
import { act, renderHook } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { useLogout } from "../useLogout";
|
|
|
|
const mockSignOut = vi.fn(() => ({ error: null }));
|
|
|
|
const mockUseSupabase = () => ({
|
|
supabase: {
|
|
auth: {
|
|
signOut: mockSignOut,
|
|
},
|
|
},
|
|
});
|
|
|
|
vi.mock("next/navigation", () => ({
|
|
useRouter: () => ({ replace: vi.fn() }),
|
|
}));
|
|
|
|
vi.mock("@/lib/context/SupabaseProvider", () => ({
|
|
useSupabase: () => mockUseSupabase(),
|
|
}));
|
|
const clearLocalStorageMock = vi.fn();
|
|
|
|
Object.defineProperty(window, "localStorage", {
|
|
value: {
|
|
clear: clearLocalStorageMock,
|
|
},
|
|
});
|
|
|
|
describe("useLogout", () => {
|
|
it("should call signOut", async () => {
|
|
const { result } = renderHook(() => useLogout());
|
|
|
|
await act(() => result.current.handleLogout());
|
|
|
|
expect(mockSignOut).toHaveBeenCalledTimes(1);
|
|
expect(clearLocalStorageMock).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|