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

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

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

  it("applies overrides", () => {
    const a = articleFactory.build({ status: "published", title: "X" });
    expect(a.status).toBe("published");
    expect(a.title).toBe("X");
  });

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