import { describe, expect, test } from "bun:test";
import { parsePlanIndexTable } from "./parse-index";

const FIXTURE = `
| Priority | Status | Plan | Scope | Current receipt |
|---:|---|---|---|---|
| FIRE | IDLE | [Master Delivery Plan](2026-08-10-master-delivery-plan.md) | navigation | split plans |
| 1 | ACTIVE | [Flow-First Operating Model](2026-08-10-flow-first-operating-model.md) | workflow | box02iakl installing |
| FIRE | BLOCKED | [Factory on k3s](2026-08-10-factory-k3s.md) | #96/#175 | Debian3 seat capacity 3/3 |
`;

describe("parsePlanIndexTable", () => {
  test("parses markdown plan index rows", () => {
    const rows = parsePlanIndexTable(FIXTURE);
    expect(rows).toHaveLength(3);
    expect(rows[0]).toMatchObject({
      priority: "FIRE",
      status: "IDLE",
      title: "Master Delivery Plan",
      href: "2026-08-10-master-delivery-plan.md",
      scope: "navigation",
      indexReceipt: "split plans",
    });
    expect(rows[1]?.status).toBe("ACTIVE");
    expect(rows[2]?.status).toBe("BLOCKED");
  });
});
