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

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

  it("returns a User with stable defaults", () => {
    const u = userFactory.build();
    expect(u.id).toBe("user-1");
    expect(u.username).toBe("user1");
    expect(u.passwordHash).toHaveLength(60);
  });

  it("applies overrides", () => {
    const u = userFactory.build({ username: "alice" });
    expect(u.username).toBe("alice");
    expect(u.id).toBe("user-1");
  });

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