# test.govlab/context/core/parsers/metadata.parser.test.ts

> 21 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-context-core-parsers-metadata-parser-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/context/core/parsers/metadata.parser.test.ts.txt

Listed in [test.govlab/context/core/parsers](https://banes-lab.com/api/source/testing/test.govlab/context/core/parsers.md), after [test.govlab/context/core/parsers/invariant.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/parsers/invariant.parser.test.ts.md) and before [test.govlab/context/core/parsers/node.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/parsers/node.parser.test.ts.md).

## Contained in

- [test.govlab/context/core/parsers](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-context-core-parsers.md)

## Source

```typescript
import { fieldOf, parseDeclaration, readFrontmatter } from "@govlab/context/core/parsers/metadata.parser.ts";
import { LINE } from "./document.fixture.ts";
import assert from "node:assert/strict";
import { test } from "vitest";

test("parseDeclaration reads the type, the verb and the description", () => {
    assert.deepEqual(parseDeclaration("THIS AGENT PERFORMS a sample task", LINE), {
        description: "a sample task",
        line: LINE,
        type: "AGENT",
        verb: "PERFORMS",
    });
});

test("readFrontmatter reads a fenced block and reports where the body starts", () => {
    assert.deepEqual(readFrontmatter(["", "---", "name: x", "---", "body"]), { end: 4, frontmatter: "name: x" });
    assert.deepEqual(readFrontmatter(["body"]), { end: 0, frontmatter: null });
});

test("fieldOf splits a line at its first colon and refuses a line that opens with one", () => {
    assert.deepEqual(fieldOf("verdict: pass: now"), { key: "verdict", value: "pass: now" });
    assert.equal(fieldOf(": no key"), null);
    assert.equal(fieldOf("no colon"), null);
});
```
