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

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

  it("returns a Header with stable defaults", () => {
    const h = headerFactory.build();
    expect(h.items).toHaveLength(0);
    expect(h.logoId).toBe("logo-1");
  });

  it("applies overrides", () => {
    const h = headerFactory.build({
      logoId: "logo-42",
      items: [{ label: "Home", href: "/", external: false }],
    });
    expect(h.logoId).toBe("logo-42");
    expect(h.items).toHaveLength(1);
    expect(h.items[0]?.label).toBe("Home");
  });

  it("builds multiple headers independently", () => {
    const a = headerFactory.build({ items: [{ label: "A", href: "/a", external: false }] });
    const b = headerFactory.build({ items: [] });
    expect(a.items).toHaveLength(1);
    expect(b.items).toHaveLength(0);
  });

  it("logoId reflects sequence for deterministic buildList output", () => {
    const first = headerFactory.build();
    const second = headerFactory.build();
    expect(first.logoId).toBe("logo-1");
    expect(second.logoId).toBe("logo-2");
  });
});
