# test.govlab/context/core/normalizers/lexicon.normalizer.test.ts

> 17 lines of code and 0 definitions.

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

Listed in [test.govlab/context/core/normalizers](https://banes-lab.com/api/source/testing/test.govlab/context/core/normalizers.md), after [test.govlab/context/core/normalizers/layer.normalizer.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/normalizers/layer.normalizer.test.ts.md) and before [test.govlab/context/core/normalizers/reason.normalizer.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/normalizers/reason.normalizer.test.ts.md).

## Contained in

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

## Source

```typescript
import assert from "node:assert/strict";
import { termNormalizer } from "@govlab/context/core/normalizers/lexicon.normalizer.ts";
import { test } from "vitest";

const RAW = { definition: "A planted term.", kind: "constraint", name: "Planted Term" };

test("a term takes its category's enforcer and shape, and the collection check merges under its own", () => {
    const normalize = termNormalizer({ population: "every term" });
    const term = normalize({ ...RAW }, "planted", null, { enforcedBy: ["a gate"], exampleShape: "placed-file" });
    assert.equal(term.id, "planted-term");
    assert.deepEqual(term.enforcedBy, ["a gate"]);
    assert.equal(term.exampleShape, "placed-file");
    assert.deepEqual(term.check, { population: "every term" });
});

test("a term refuses an undeclared example shape and a record missing its definition", () => {
    const normalize = termNormalizer(null);
    assert.throws(() => normalize({ ...RAW }, "planted", null, { exampleShape: "ghost" }));
    assert.throws(() => normalize({ kind: "constraint", name: "N" }, "planted", null, {}));
});
```
