# test.govlab/patterns/core/models/graph.model.test.ts

> 17 lines of code and 0 definitions.

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

Listed in [test.govlab/patterns/core/models](https://banes-lab.com/api/source/testing/test.govlab/patterns/core/models.md).

## Contained in

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

## Source

```typescript
import { describe, expect, it } from "vitest";
import { AnalysisGraph } from "@govlab/patterns/core/models/graph.model.ts";
import { GraphError } from "@govlab/patterns/core/validators/graph.validator.ts";
import { sourceNode } from "@govlab/patterns/core/factories/node.factory.ts";

describe("AnalysisGraph", () => {
    it("holds its nodes and validates them on demand", () => {
        const graph = new AnalysisGraph([sourceNode()]);
        graph.validate();
        expect(graph.nodes).toHaveLength(1);
    });

    it("surfaces a validation failure as a GraphError", () => {
        const graph = new AnalysisGraph([sourceNode(), sourceNode()]);
        expect(() => {
            graph.validate();
        }).toThrow(GraphError);
    });
});
```
