# test.govlab/context/core/resolvers/reason.resolver.test.ts

> 18 lines of code and 0 definitions.

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

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

## Contained in

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

## Source

```typescript
import { buildIndexes, conceptResolver, resolveId } from "@govlab/context/core/resolvers/reason.resolver.ts";
import assert from "node:assert/strict";
import { bundledReason } from "../validators/ontology.fixture.ts";
import { test } from "vitest";

test("buildIndexes indexes every reason node by id", () => {
    const data = bundledReason();
    const [first] = data.nodes;
    assert.ok(first);
    assert.equal(buildIndexes(data).node.get(first.id)?.id, first.id);
});

test("resolveId resolves the derivation loop id to the loop record", () => {
    const data = bundledReason();
    assert.equal(resolveId(data, buildIndexes(data))(data.derivationLoop.id)?.kind, "loop");
});

test("conceptResolver is a callable node resolver", () => {
    const { concepts } = buildIndexes(bundledReason());
    assert.equal(typeof conceptResolver(concepts), "function");
});
```
