import { describe, it, expect, beforeEach } from "vitest";
import { sessionFactory } from "@/__factories__/session.factory";

describe("sessionFactory", () => {
  beforeEach(() => sessionFactory.reset());

  it("returns a Session with stable defaults", () => {
    const s = sessionFactory.build();
    expect(s.id).toBe("session-1");
    expect(s.userId).toBe("user-1");
    expect(s.expiresAt).toBeInstanceOf(Date);
  });

  it("applies overrides", () => {
    const s = sessionFactory.build({ userId: "user-42" });
    expect(s.userId).toBe("user-42");
    expect(s.id).toBe("session-1");
  });

  it("increments sequence per build", () => {
    const a = sessionFactory.build();
    const b = sessionFactory.build();
    expect(a.id).toBe("session-1");
    expect(b.id).toBe("session-2");
  });
});
