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

> 12 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-graph-factory-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/patterns/core/factories/graph.factory.test.ts.txt

Listed in [test.govlab/patterns/core/factories](https://banes-lab.com/api/source/testing/test.govlab/patterns/core/factories.md), after [test.govlab/patterns/core/factories/finding.factory.test.ts](https://banes-lab.com/source/testing/test.govlab/patterns/core/factories/finding.factory.test.ts.md) and before [test.govlab/patterns/core/factories/node.factory.test.ts](https://banes-lab.com/source/testing/test.govlab/patterns/core/factories/node.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 { describe, expect, it } from "vitest";
import { GraphError } from "@govlab/patterns/core/validators/graph.validator.ts";
import { graphOf } from "@govlab/patterns/core/factories/graph.factory.ts";
import { sourceNode } from "@govlab/patterns/core/factories/node.factory.ts";

describe("graphOf", () => {
    it("returns a validated graph over the nodes", () => {
        expect(graphOf([sourceNode()]).nodes).toHaveLength(1);
    });

    it("refuses an invalid node set before returning", () => {
        expect(() => graphOf([sourceNode(), sourceNode()])).toThrow(GraphError);
    });
});
```
