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

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

  it("returns a Page with stable defaults", () => {
    const p = pageFactory.build();
    expect(p.id).toBe("page-1");
    expect(p.title).toBe("Page 1");
    expect(p.slug).toBe("page-1");
    expect(p.status).toBe("draft");
    expect(p.createdAt).toEqual(new Date("2026-01-01T00:00:00Z"));
  });

  it("applies overrides", () => {
    const p = pageFactory.build({ status: "published", title: "About" });
    expect(p.status).toBe("published");
    expect(p.title).toBe("About");
    expect(p.id).toBe("page-1");
  });

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