# tests/core/inspectors/board.inspector.test.ts

> 89 lines of code and 0 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tests-core-inspectors-board-inspector-test-ts
Source text: https://banes-lab.com/assets/sources/source.530667fcef016d0b797c99aa8b6d0b8225ddf2c2fd74c093f9dcee5047b803d2.generated.txt

## Source

```typescript
import {
    checkIndex,
    checkItemAddressing,
    checkItemFences,
    checkItemLetters,
    checkReadable,
    checkTemplateDrift,
    letterOfLabel,
    readerSet,
} from "../../../tools/core/inspectors/board.inspector.ts";
import { describe, it } from "node:test";
import type { Finding } from "../../../tools/core/types/segment.types.ts";
import { READ_BUDGET_CHARS } from "../../../tools/core/constants/board.constants.ts";
import assert from "node:assert/strict";

const BOARD = [
    "Agent A — ACTIVE",
    "┌─── AGENT A",
    "┌─── AGENT B-1 at:5 to:A",
    "a peer's item inside A's record",
    "└─── END AGENT B-1",
    "┌─── AGENT A-2",
    "└─── END AGENT A-2",
    "└─── END AGENT A",
    "┌─── AGENT A-3 at:9",
].join("\n");

const lociOf = function lociOf(findings: readonly Finding[]): string[] {
    return findings.map((finding) => finding.locus);
};

describe("readerSet", () => {
    it("reads the named letters of an addressed line and nothing for a broadcast or role address", () => {
        assert.deepEqual(readerSet("To B, C — read the draft"), ["B", "C"]);
        assert.deepEqual(readerSet("To ALL — everyone"), []);
        assert.deepEqual(readerSet("To WHOEVER holds review — take it"), []);
        assert.deepEqual(readerSet("To B without a terminator"), []);
        assert.deepEqual(readerSet("plain prose"), []);
    });
});

describe("letterOfLabel", () => {
    it("reads the letter after a record's kind word, or keeps a bare label", () => {
        assert.equal(letterOfLabel("Agent B"), "B");
        assert.equal(letterOfLabel("B"), "B");
    });
});

describe("checkIndex", () => {
    it("reports a letter bound twice and an agent writing under an unbound letter", () => {
        const index = "| A | governance | ACTIVE |\n| A | document | ACTIVE |";
        const records = [
            { kind: "agent", label: "Agent A", line: 1 },
            { kind: "agent", label: "Agent B", line: 3 },
            { kind: "gate", label: "Gate converge", line: 5 },
        ];
        assert.deepEqual(lociOf(checkIndex(records, index)), ["A", "B"]);
    });
});

describe("checkTemplateDrift", () => {
    it("reports a record kind whose template fields differ from the schema, and nothing when they agree", () => {
        const gate = "Gate <id> — <state>\n  State: <v>\n  Owner: <v>\n  Blocker: <v>";
        const drifted = `Agent <letter> — <ACTIVE>\n  Owns: <v>\n  Status: <v>\n\n${gate}`;
        const agreed = `Agent <letter> — <ACTIVE>\n  Owns: <v>\n  Status: <v>\n  Flags: —\n  Refs: —\n\n${gate}`;
        assert.deepEqual(lociOf(checkTemplateDrift(drifted)), ["agent"]);
        assert.deepEqual(checkTemplateDrift(agreed), []);
    });
});

describe("checkReadable", () => {
    it("reports a line past the read budget at its own line number", () => {
        const long = "x".repeat(READ_BUDGET_CHARS + 1);
        const findings = checkReadable(`short\n${long}`);
        assert.deepEqual(
            findings.map((finding) => finding.line),
            [2],
        );
        assert.deepEqual(checkReadable("short"), []);
    });
});

describe("checkItemAddressing", () => {
    it("reports an item whose text names an addressee while its metadata broadcasts", () => {
        assert.deepEqual(lociOf(checkItemAddressing("meta to:*\nTo B — only one reader")), ["To B — only one reader"]);
    });
});

describe("checkItemLetters", () => {
    it("reports an item sitting inside a record its key letter does not name", () => {
        assert.deepEqual(lociOf(checkItemLetters(BOARD)), ["B-1"]);
    });
});

describe("checkItemFences", () => {
    it("reports an item opened without a stamp and an item missing its close", () => {
        assert.deepEqual(lociOf(checkItemFences(BOARD)), ["A-2", "A-3"]);
    });
});
```
