# test.govlab/patterns/core/factories/axis.factory.test.ts

> 25 lines of code and 0 definitions.

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

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

## Contained in

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

## Source

```typescript
import { CoordinateError, coordinate } from "@govlab/patterns/core/factories/axis.factory.ts";
import { describe, expect, it } from "vitest";
import { REPRESENTATION_AXIS } from "@govlab/patterns/configuration/generated/axis.generated.ts";
import { unknownTag } from "@govlab/patterns/configuration/strings/axis.strings.ts";

const INPUT = { analysis: "frequency", ontology: "probability", reasoning: "explanation", representation: "symbolic" };

describe("coordinate", () => {
    it("stamps all four axes and freezes the result", () => {
        const stamped = coordinate(INPUT);
        expect(stamped).toStrictEqual(INPUT);
        expect(Object.isFrozen(stamped)).toBe(true);
    });

    it("accepts every representation the ontology declares", () => {
        for (const representation of REPRESENTATION_AXIS) {
            expect(coordinate({ ...INPUT, representation }).representation).toBe(representation);
        }
    });

    it("refuses an off-vocabulary tag on any axis with a CoordinateError", () => {
        expect(() => coordinate({ ...INPUT, ontology: "nonsense" })).toThrow(CoordinateError);
        expect(() => coordinate({ ...INPUT, analysis: "nonsense" })).toThrow(CoordinateError);
        expect(() => coordinate({ ...INPUT, reasoning: "guessing" })).toThrow(CoordinateError);
        expect(() => coordinate({ ...INPUT, representation: "graphical" })).toThrow(
            unknownTag("representation", "graphical"),
        );
    });
});
```
