# tests/core/readers/record.reader.test.ts

> 36 lines of code and 0 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tests-core-readers-record-reader-test-ts
Source text: https://banes-lab.com/assets/sources/source.5af670589b68d0790f9170739207aaaaf1596a60a0fa44988acc4fef0c84ea6e.generated.txt

## Source

```typescript
import { citedIds, readRecordDocument } from "../../../tools/core/readers/record.reader.ts";
import { describe, it } from "node:test";
import assert from "node:assert/strict";

const SOURCE = [
    "---",
    "records: keyed",
    "---",
    "# Records",
    "### AB-01",
    "owner: A",
    "not a key: skipped",
    "owner: B",
    "### AB-02",
    "state: open",
    "## Next section",
    "stray: ignored",
].join("\n");

describe("readRecordDocument", () => {
    it("reads the declared shape and each record's keys, closing a record at the next heading", () => {
        assert.deepEqual(readRecordDocument(SOURCE), {
            records: [
                { id: "AB-01", keys: { owner: "B" }, line: 5 },
                { id: "AB-02", keys: { state: "open" }, line: 9 },
            ],
            shape: "keyed",
        });
    });

    it("defaults to typed records", () => {
        assert.equal(readRecordDocument("### X").shape, "typed");
    });
});

describe("citedIds", () => {
    it("reads each identifier with two capitals and two digits once", () => {
        assert.deepEqual(citedIds("see AB-12, AB-12 and A-1, abc-12, ZZ-99"), ["AB-12", "ZZ-99"]);
    });
});
```
