# test.build/core/converters/grammar.reference.converter.test.ts

> 25 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-build-core-converters-grammar-reference-converter-test-ts
Source text: https://banes-lab.com/source/testing/test.build/core/converters/grammar.reference.converter.test.ts.txt

Listed in [test.build/core/converters](https://banes-lab.com/api/source/testing/test.build/core/converters.md), after [test.build/core/converters/grammar.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/grammar.converter.test.ts.md) and before [test.build/core/converters/graph.code.converter.test.ts](https://banes-lab.com/source/testing/test.build/core/converters/graph.code.converter.test.ts.md).

## Contained in

- [test.build/core/converters](https://banes-lab.com/anatomy/testing/folder-testing-test-build-core-converters.md)

## Source

```typescript
import { createResolver, refOf } from "@banes-lab/build-scripts/core/resolvers/ontology.resolver.ts";
import { describe, expect, it } from "vitest";
import { PAG_FACE } from "@govlab/constants";
import { createGovlabContext } from "@govlab/context";
import { grammarOf } from "@banes-lab/build-scripts/core/converters/grammar.converter.ts";
import { pagReferencesOf } from "@banes-lab/build-scripts/core/converters/grammar.reference.converter.ts";

const context = createGovlabContext();
const grammar = grammarOf(context, createResolver(context));
const index = pagReferencesOf(grammar);

describe("pagReferencesOf", () => {
    it("keys each document type and template record by its anchor under the grammar face", () => {
        for (const documentType of grammar.documentTypes) {
            expect(index[refOf(PAG_FACE, documentType.anchor)]?.name).toBe(documentType.type);
        }
        for (const template of grammar.templates) {
            expect(index[refOf(PAG_FACE, template.anchor)]?.name).toBe(template.title);
        }
    });

    it("carries a keyword's primary meaning as its summary", () => {
        const [keyword] = grammar.categories.flatMap((category) => category.keywords);
        expect(keyword === undefined ? null : index[refOf(PAG_FACE, keyword.anchor)]?.summary).toBe(
            keyword?.roles[0].meaning ?? null,
        );
    });
});
```
