# tests/core/runners/agenda.runner.test.ts

> 41 lines of code and 0 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tests-core-runners-agenda-runner-test-ts
Source text: https://banes-lab.com/assets/sources/source.71ab43f60eb23dd21a6846446c0bb4fe2efc66865008d5f0c0922bc0ae943f07.generated.txt

## Source

```typescript
import {
    SCHEDULE_HEADER,
    SCHEDULE_RULE,
    healSchedule,
    scheduleBounds,
} from "../../../tools/core/runners/agenda.runner.ts";
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { sameRow } from "../../../tools/core/normalizers/document.normalizer.ts";

const RENDERED = [SCHEDULE_HEADER, SCHEDULE_RULE, "| 1 | `a` | b | planned |"];

const FORMATTED = [
    "prose",
    "",
    "| planned | invariant | what it must establish | state   |",
    "| ------- | --------- | ---------------------- | ------- |",
    "| 1       | `a`       | b                      | planned |",
    "",
    "after",
];

describe("sameRow", () => {
    it("compares table rows by their cells, so a formatter's padding is not a difference", () => {
        assert.equal(sameRow(FORMATTED[2] ?? "", SCHEDULE_HEADER), true);
        assert.equal(sameRow(FORMATTED[3] ?? "", SCHEDULE_RULE), true);
        assert.equal(sameRow("| 1 | `a` | b | open |", RENDERED[2] ?? ""), false);
        assert.equal(sameRow("| 1 | `a` | b |", RENDERED[2] ?? ""), false);
    });
});

describe("scheduleBounds and healSchedule", () => {
    it("finds a formatted table and leaves it alone when its cells already hold the rendering", () => {
        assert.deepEqual(scheduleBounds(FORMATTED), { from: 2, to: 4 });
        assert.equal(healSchedule(FORMATTED.join("\n"), RENDERED), null);
    });

    it("rewrites the table region when a cell disagrees with the rendering", () => {
        const drifted = FORMATTED.map((line, index) => (index === 4 ? "| 1 | `a` | b | open |" : line));
        const healed = healSchedule(drifted.join("\n"), RENDERED);
        assert.equal(healed, ["prose", "", ...RENDERED, "", "after"].join("\n"));
    });

    it("finds no table when the header is absent", () => {
        assert.equal(scheduleBounds(["| other | header |"]), null);
    });
});
```
