import { describe, it, expect } from "vitest";
import { buildCheckTargets } from "./lib/discovery";

describe("buildCheckTargets", () => {
  it("generates module targets when modulesRoot is set", () => {
    const targets = buildCheckTargets({ modulesRoot: "modules", appRoot: undefined });
    expect(targets).toEqual([
      { glob: "modules/[a-zA-Z]*/docs/features/*.md", schemaKey: "feature" },
      { glob: "modules/[a-zA-Z]*/docs/commands/*.md", schemaKey: "command" },
      { glob: "modules/[a-zA-Z]*/docs/models/*.md", schemaKey: "model" },
      { glob: "modules/[a-zA-Z]*/docs/queries/*.md", schemaKey: "query" },
      { glob: "modules/[a-zA-Z]*/README.md", schemaKey: "module" },
    ]);
  });

  it("generates app-compose targets when appRoot is set", () => {
    const targets = buildCheckTargets({ modulesRoot: undefined, appRoot: "apps/myapp" });
    expect(targets[0].glob).toBe("apps/myapp/README.md");
    expect(targets).toHaveLength(6);
  });

  it("generates both when both roots are set", () => {
    const targets = buildCheckTargets({ modulesRoot: "modules", appRoot: "examples/app1" });
    expect(targets).toHaveLength(11);
  });

  it("returns empty when neither root is set", () => {
    const targets = buildCheckTargets({ modulesRoot: undefined, appRoot: undefined });
    expect(targets).toHaveLength(0);
  });
});
