import { describe, it, expect } from "vitest"; import { SIGNED_IN_ELSEWHERE_COOKIE, signedInElsewhere } from "./signedInElsewhere"; // one-session-per-account: the login page reads a short-lived marker the server sets when a newer sign-in ended this // browser's session. describe("signedInElsewhere", () => { it("is true when the marker cookie is present", () => { expect(signedInElsewhere(`a=1; ${SIGNED_IN_ELSEWHERE_COOKIE}=1; b=2`)).toBe(true); }); it("is false without the marker, or with an empty one", () => { expect(signedInElsewhere("a=1")).toBe(false); expect(signedInElsewhere(`${SIGNED_IN_ELSEWHERE_COOKIE}=`)).toBe(false); expect(signedInElsewhere("")).toBe(false); }); it("uses a host-only cookie name", () => { expect(SIGNED_IN_ELSEWHERE_COOKIE.startsWith("__Host-")).toBe(true); }); });