From e3ebfcb2657703e833686f7400071b6f1c732511 Mon Sep 17 00:00:00 2001 From: Philipp Date: Tue, 16 Jan 2024 15:22:56 +0100 Subject: [PATCH] test: add `AutoPlaceUtil` type tests --- lib/features/auto-place/AutoPlaceUtil.spec.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/features/auto-place/AutoPlaceUtil.spec.ts diff --git a/lib/features/auto-place/AutoPlaceUtil.spec.ts b/lib/features/auto-place/AutoPlaceUtil.spec.ts new file mode 100644 index 000000000..7a720c4bf --- /dev/null +++ b/lib/features/auto-place/AutoPlaceUtil.spec.ts @@ -0,0 +1,29 @@ +import Diagram from '../../Diagram'; + +import ElementFactory from '../../core/ElementFactory'; + +import { + findFreePosition, + generateGetNextPosition, + getConnectedDistance +} from './AutoPlaceUtil'; + +const diagram = new Diagram(); + +const elementFactory = diagram.get('elementFactory'); + +const source = elementFactory.createShape(), + element = elementFactory.createShape(); + +const getNextPosition = generateGetNextPosition({ x: 100, y: 100 }); + +findFreePosition(source, element, { x: 100, y: 100 }, getNextPosition); + +getConnectedDistance(source, { + defaultDistance: 100, + direction: 'right', + filter: (connection) => true, + getWeight: (connection) => 1, + maxDistance: 100, + reference: 'center' +}); \ No newline at end of file