import { describe, expect, it } from 'vitest'; import { graphCardConnection } from '../../src/features/mitre-graph/graph-card-connection'; describe('graph card connection geometry', () => { it('connects the node ring to the nearest card edge', () => { expect(graphCardConnection( { x: 0, y: 0, radius: 10 }, { x: 30, y: -20, width: 80, height: 40 } )).toEqual({ startX: 15, startY: 0, endX: 30, endY: 0 }); }); it('keeps a visible connector when a manually placed card overlaps the node', () => { const connection = graphCardConnection( { x: 10, y: 10, radius: 4 }, { x: 0, y: 0, width: 40, height: 30 } ); expect(connection.endX === 0 || connection.endX === 40 || connection.endY === 0 || connection.endY === 30).toBe(true); expect(Math.hypot(connection.endX - connection.startX, connection.endY - connection.startY)).toBeGreaterThan(0); }); });