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: "{}", }); }); });