test.govlab/patterns/core/models/graph.model.test.ts
test.govlab/patterns/core/models/graph.model.test.ts is a file in Codebase Testing. 17 lines of code and 0 definitions.
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);
});
});