capabilityMapSystemPlacement.test.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. CAPABILITY_MAP_ROOT_PADDING,
  4. CAPABILITY_MAP_SYSTEM_GAP,
  5. ENGINEERING_INFRASTRUCTURE_SYSTEM_ID,
  6. buildCapabilitySystemPositions,
  7. } from "@/capability-map/capabilityMapSystemPlacement.js";
  8. describe("能力图顶层区域布局", () => {
  9. it("前三个运行层横向排列,工程基础设施居中放在下方", () => {
  10. const positions = buildCapabilitySystemPositions([
  11. { id: "renderer", width: 100, height: 200 },
  12. { id: "host", width: 120, height: 180 },
  13. { id: "zcode-cli", width: 80, height: 220 },
  14. {
  15. id: ENGINEERING_INFRASTRUCTURE_SYSTEM_ID,
  16. width: 160,
  17. height: 100,
  18. },
  19. ]);
  20. expect(positions.get("renderer")).toEqual({
  21. x: CAPABILITY_MAP_ROOT_PADDING,
  22. y: CAPABILITY_MAP_ROOT_PADDING,
  23. });
  24. expect(positions.get("host")).toEqual({
  25. x: CAPABILITY_MAP_ROOT_PADDING + 100 + CAPABILITY_MAP_SYSTEM_GAP,
  26. y: CAPABILITY_MAP_ROOT_PADDING,
  27. });
  28. expect(positions.get("zcode-cli")).toEqual({
  29. x:
  30. CAPABILITY_MAP_ROOT_PADDING +
  31. 100 +
  32. CAPABILITY_MAP_SYSTEM_GAP +
  33. 120 +
  34. CAPABILITY_MAP_SYSTEM_GAP,
  35. y: CAPABILITY_MAP_ROOT_PADDING,
  36. });
  37. expect(positions.get(ENGINEERING_INFRASTRUCTURE_SYSTEM_ID)).toEqual({
  38. x: 134,
  39. y:
  40. CAPABILITY_MAP_ROOT_PADDING +
  41. 220 +
  42. CAPABILITY_MAP_SYSTEM_GAP,
  43. });
  44. });
  45. });