Files
PaperClipAI/ui/src/api/auth.test.ts
T
2026-08-03 22:34:14 -05:00

30 lines
865 B
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { authApi } from "./auth";
describe("authApi.signOut", () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it("returns the managed deployment redirect from the response", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ success: true, redirectTo: "/cloud/logout" }), {
status: 200,
headers: { "Content-Type": "application/json" },
}),
);
vi.stubGlobal("fetch", fetchMock);
await expect(authApi.signOut()).resolves.toEqual({
success: true,
redirectTo: "/cloud/logout",
});
expect(fetchMock).toHaveBeenCalledWith("/api/auth/sign-out", {
method: "POST",
credentials: "include",
headers: { "Content-Type": "application/json" },
body: "{}",
});
});
});