import { describe, it, expect } from "vitest";
import { formatSyncCheckReport } from "./format";
import type { SyncCheckResult } from "./shared";

describe("formatSyncCheckReport", () => {
  it("passes when files were checked and there are no errors", () => {
    const out = formatSyncCheckReport({ errors: [], filesChecked: 2 });
    expect(out).toContain("Files checked: 2");
    expect(out).toContain("docs-sync-check passed.");
  });

  it("fails when no files were checked", () => {
    const out = formatSyncCheckReport({ errors: [], filesChecked: 0 });
    expect(out).toContain("Files checked: 0");
    expect(out).toContain("no files were checked");
    expect(out).not.toContain("docs-sync-check passed.");
  });

  it("reports failure when there are errors", () => {
    const result: SyncCheckResult = {
      errors: [{ type: "missing-doc", category: "command", expectedBasename: "createOrder" }],
      filesChecked: 1,
    };
    expect(formatSyncCheckReport(result)).toContain("failed with 1 error(s)");
  });
});
