Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

test: add alias chain detection guards

Lum11044b22ed73369a
diff --git a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
index 5e9dd4a0..24edb518 100644
--- a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
+++ b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts
@@ -1,5 +1,10 @@
import { describe, it, expect } from "vitest";
-import { validateGraph, normalizeGraph } from "../schema.js";
+import {
+ validateGraph,
+ normalizeGraph,
+ NODE_TYPE_ALIASES,
+ EDGE_TYPE_ALIASES,
+} from "../schema.js";
import type { KnowledgeGraph } from "../types.js";
const validGraph: KnowledgeGraph = {
@@ -239,4 +244,22 @@ describe("schema validation", () => {
const result = validateGraph(graph);
expect(result.success).toBe(false);
});
+
+ it("NODE_TYPE_ALIASES values are never alias keys (no chains)", () => {
+ for (const [alias, target] of Object.entries(NODE_TYPE_ALIASES)) {
+ expect(
+ NODE_TYPE_ALIASES,
+ `chain detected: ${alias} → ${target} → ${NODE_TYPE_ALIASES[target]}`,
+ ).not.toHaveProperty(target);
+ }
+ });
+
+ it("EDGE_TYPE_ALIASES values are never alias keys (no chains)", () => {
+ for (const [alias, target] of Object.entries(EDGE_TYPE_ALIASES)) {
+ expect(
+ EDGE_TYPE_ALIASES,
+ `chain detected: ${alias} → ${target} → ${EDGE_TYPE_ALIASES[target]}`,
+ ).not.toHaveProperty(target);
+ }
+ });
});