capabilityMapComplexity.test.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { describe, expect, it, vi } from "vitest";
  2. import { groupComplexityById } from "@/capability-map/capabilityMapTypes.js";
  3. // 原测试依赖当前能力图,并把缺失端点误计为跨群边,导致 136 != 137。
  4. // 使用固定小图独立声明期望,不让文档节点增删或统计实现决定测试答案。
  5. vi.mock("@/data/productCapabilityMap.js", () => ({
  6. capabilityGroups: [{ id: "a" }, { id: "b" }, { id: "c" }, { id: "empty" }],
  7. capabilityNodes: [
  8. { id: "a1", groupId: "a" },
  9. { id: "a2", groupId: "a" },
  10. { id: "b1", groupId: "b" },
  11. { id: "c1", groupId: "c" },
  12. { id: "orphan", groupId: "missing-group" },
  13. ],
  14. capabilityEdges: [
  15. { source: "a1", target: "b1" },
  16. { source: "b1", target: "a1" },
  17. { source: "b1", target: "c1" },
  18. { source: "a1", target: "a2" },
  19. { source: "missing-node", target: "b1" },
  20. { source: "a1", target: "missing-node" },
  21. { source: "orphan", target: "b1" },
  22. ],
  23. capabilitySystems: [],
  24. capabilityRelationNames: {},
  25. }));
  26. describe("能力群复杂度", () => {
  27. it("只把跨群有向边计入入度和出度", () => {
  28. expect([...groupComplexityById]).toEqual([
  29. ["a", { inDegree: 1, outDegree: 1 }],
  30. ["b", { inDegree: 1, outDegree: 2 }],
  31. ["c", { inDegree: 1, outDegree: 0 }],
  32. ["empty", { inDegree: 0, outDegree: 0 }],
  33. ]);
  34. });
  35. });