import { describe, it, expect } from "vitest";
import {
  isGuestSession,
  type GuestSession,
  type AuthenticatedSession,
  type CartSession,
} from "./types";

describe("session types", () => {
  describe("isGuestSession", () => {
    it("returns true for GuestSession", () => {
      const session: GuestSession = { sessionId: "uuid-123", isGuest: true };
      expect(isGuestSession(session)).toBe(true);
    });

    it("returns false for AuthenticatedSession", () => {
      const session: AuthenticatedSession = {
        sessionId: undefined,
        isGuest: false,
      };
      expect(isGuestSession(session)).toBe(false);
    });

    it("narrows type to GuestSession when true", () => {
      const session: CartSession = { sessionId: "uuid-456", isGuest: true };
      if (isGuestSession(session)) {
        expect(session.sessionId).toBe("uuid-456");
      }
    });
  });
});
