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

> 16 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-architecture-normalizer-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/context/core/normalizers/architecture.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/algorithm.normalizer.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/normalizers/algorithm.normalizer.test.ts.md) and before [test.govlab/context/core/normalizers/field.normalizer.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/normalizers/field.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 { normalizePrinciple } from "@govlab/context/core/normalizers/architecture.normalizer.ts";
import { plantedPrinciple } from "../validators/ontology.fixture.ts";
import { test } from "vitest";

const [record] = plantedPrinciple("", { name: "Planted Rule" }).records;
const raw = Object.fromEntries(Object.entries(record ?? {}).filter(([key]) => key !== "id"));

test("normalizePrinciple derives the id from the name, keeps the category and drops the empty optional fields", () => {
    const principle = normalizePrinciple(raw, "planted", null);
    assert.equal(principle.id, "planted-rule");
    assert.equal(principle.category, "planted");
    assert.equal("mandatoryFor" in principle, false);
    assert.equal("canon" in principle, false);
});

test("normalizePrinciple refuses a severity outside the closed levels", () => {
    assert.throws(() => normalizePrinciple({ ...raw, severity: "high" }, "planted", null));
});
```
