mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-09 06:15:21 +02:00
30 lines
865 B
TypeScript
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: "{}",
|
|
});
|
|
});
|
|
});
|