# test.govlab/patterns/core/analyzers/field.analyzer.test.ts

> 22 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-patterns-core-analyzers-field-analyzer-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/patterns/core/analyzers/field.analyzer.test.ts.txt

Listed in [test.govlab/patterns/core/analyzers](https://banes-lab.com/api/source/testing/test.govlab/patterns/core/analyzers.md), after [test.govlab/patterns/core/analyzers/dependency.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/patterns/core/analyzers/dependency.analyzer.test.ts.md) and before [test.govlab/patterns/core/analyzers/information.analyzer.test.ts](https://banes-lab.com/source/testing/test.govlab/patterns/core/analyzers/information.analyzer.test.ts.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { FieldAnalyzer } from "@govlab/patterns/core/analyzers/field.analyzer.ts";
import { registerRepresentation } from "@govlab/patterns/core/registries/representation.registry.ts";

describe("FieldAnalyzer", () => {
    it("binds each registered representation and emits an analysis node per productive one", () => {
        const analyzer = new FieldAnalyzer("color", ["distribution", "unregistered"]);
        analyzer.update([{ color: "red" }, { color: "blue" }]);
        const { nodes, findings } = analyzer.produce();
        expect(nodes[0]?.id).toBe("color:distribution");
        expect(nodes).toHaveLength(findings.length + 1);
    });

    it("emits no node for a representation that produces no finding", () => {
        registerRepresentation({
            applicable: [],
            create() {
                return { findings: () => [], sample: () => null, update: () => {} };
            },
            name: "silent",
        });
        expect(new FieldAnalyzer("color", ["silent"]).produce()).toStrictEqual({ findings: [], nodes: [] });
    });
});
```
