tranth3truong's picture
Deploy public Scribe-only CarePath Space
cc678b9
Raw
History Blame Contribute Delete
685 Bytes
import { afterEach, describe, expect, it, vi } from "vitest";
import { deleteSession, endSession } from "./api";
afterEach(() => vi.unstubAllGlobals());
describe("session lifecycle API", () => {
it("calls the existing end and delete endpoints", async () => {
const fetch = vi.fn().mockResolvedValue({ ok: true });
vi.stubGlobal("fetch", fetch);
await endSession("session-1");
await deleteSession("session-1");
expect(fetch).toHaveBeenNthCalledWith(1, expect.stringContaining("/api/sessions/session-1/end"), { method: "POST" });
expect(fetch).toHaveBeenNthCalledWith(2, expect.stringContaining("/api/sessions/session-1"), { method: "DELETE" });
});
});