# test.govlab/context/core/loaders/algorithm.loader.test.ts

> 35 lines of code and 0 definitions.

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

Listed in [test.govlab/context/core/loaders](https://banes-lab.com/api/source/testing/test.govlab/context/core/loaders.md), before [test.govlab/context/core/loaders/architecture.loader.test.ts](https://banes-lab.com/source/testing/test.govlab/context/core/loaders/architecture.loader.test.ts.md).

## Contained in

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

## Source

```typescript
import { buildSymbolIndex, symbolIndexesMatch } from "@govlab/context";
import { loadBundledSymbols, loadContracts, symbolsPath } from "@govlab/context/core/loaders/algorithm.loader.ts";
import { ReadAudit } from "@govlab/context/core/observers/record.observer.ts";
import assert from "node:assert/strict";
import { test } from "vitest";

test("the bundled contracts load and the committed symbol index matches them", () => {
    const contracts = loadContracts(new ReadAudit("algorithms"));
    assert.ok(contracts.length > 0);
    assert.ok(symbolsPath().endsWith(".generated.json"));
    assert.equal(symbolIndexesMatch(loadBundledSymbols(), buildSymbolIndex(contracts)), true);
});

test("loadContracts folds planted categories instead of the bundled data", () => {
    const contracts = loadContracts(new ReadAudit("algorithms"), [
        {
            category: "planted",
            records: [
                {
                    composes: [],
                    flow: [],
                    force: [],
                    id: "c1",
                    intent: "i",
                    invariant: "v",
                    productions: [],
                    title: "t",
                },
            ],
            tier: "leaf",
        },
    ]);
    assert.deepEqual(
        contracts.map((entry) => entry.id),
        ["c1"],
    );
});
```
