@eclipse-glsp/client 2.8.0-next.12 → 2.8.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/lib/base/model/glsp-model-source.d.ts +1 -1
  2. package/lib/base/model/glsp-model-source.d.ts.map +1 -1
  3. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  4. package/lib/features/tool-palette/tool-palette.js +2 -4
  5. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/base/model/glsp-model-source.ts +1 -1
  8. package/src/features/tool-palette/tool-palette.ts +2 -4
  9. package/src/base/action-dispatcher.spec.ts +0 -366
  10. package/src/base/feedback/feedback-emitter.spec.ts +0 -176
  11. package/src/base/model/model-initialization-constraint.spec.ts +0 -95
  12. package/src/base/selection-service.spec.ts +0 -318
  13. package/src/default-modules.spec.ts +0 -56
  14. package/src/features/bounds/freeform-layout.spec.ts +0 -216
  15. package/src/features/bounds/hbox-layout.spec.ts +0 -170
  16. package/src/features/bounds/layouter-test-util.spec.ts +0 -127
  17. package/src/features/bounds/vbox-layout.spec.ts +0 -170
  18. package/src/features/change-bounds/point-position-updater.spec.ts +0 -81
  19. package/src/features/grid/grid-snapper.spec.ts +0 -30
  20. package/src/features/hints/type-hint-provider.spec.ts +0 -360
  21. package/src/features/layout/layout-elements-action.spec.ts +0 -426
  22. package/src/features/navigation/navigation-target-resolver.spec.ts +0 -56
  23. package/src/features/routing/sticky-manhattan-edge-router.spec.ts +0 -212
  24. package/src/features/tools/marquee-selection/marquee-behavior.spec.ts +0 -176
  25. package/src/features/validation/marker-navigator.spec.ts +0 -183
  26. package/src/utils/gmodel-util.spec.ts +0 -221
@@ -1,176 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2021-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
-
17
- import { DOMHelper } from '@eclipse-glsp/sprotty';
18
- import { expect } from 'chai';
19
- import { IMarqueeBehavior, MarqueeUtil } from './marquee-behavior';
20
-
21
- describe('MarqueeUtil', () => {
22
- function initUtil(marqueeBehavior?: IMarqueeBehavior): MarqueeUtil {
23
- const util = new MarqueeUtil(marqueeBehavior, new DOMHelper());
24
- util.updateStartPoint({ x: 0, y: 0 });
25
- util.updateCurrentPoint({ x: 0, y: 0 });
26
- return util;
27
- }
28
-
29
- describe('Node marquee', () => {
30
- const node = { x: 20, y: 20, width: 200, height: 50 };
31
-
32
- it('touch element', () => {
33
- const util = initUtil();
34
- expect(util.isNodeMarked(node)).is.equals(false);
35
- util.updateCurrentPoint({ x: 30, y: 50 });
36
- expect(util.isNodeMarked(node)).is.equals(true);
37
- util.updateCurrentPoint({ x: 250, y: 85 });
38
- expect(util.isNodeMarked(node)).is.equals(true);
39
- util.updateStartPoint({ x: 30, y: 25 });
40
- expect(util.isNodeMarked(node)).is.equals(true);
41
- });
42
-
43
- it('touch element (reverse)', () => {
44
- const util = initUtil();
45
- expect(util.isNodeMarked(node)).is.equals(false);
46
- util.updateStartPoint({ x: 30, y: 50 });
47
- expect(util.isNodeMarked(node)).is.equals(true);
48
- util.updateStartPoint({ x: 250, y: 85 });
49
- expect(util.isNodeMarked(node)).is.equals(true);
50
- util.updateCurrentPoint({ x: 30, y: 25 });
51
- expect(util.isNodeMarked(node)).is.equals(true);
52
- });
53
-
54
- it('mark entire element', () => {
55
- const util = initUtil({ entireElement: true, entireEdge: false });
56
- expect(util.isNodeMarked(node)).is.equals(false);
57
- util.updateCurrentPoint({ x: 30, y: 50 });
58
- expect(util.isNodeMarked(node)).is.equals(false);
59
- util.updateCurrentPoint({ x: 250, y: 85 });
60
- expect(util.isNodeMarked(node)).is.equals(true);
61
- util.updateStartPoint({ x: 30, y: 85 });
62
- expect(util.isNodeMarked(node)).is.equals(false);
63
- });
64
-
65
- it('mark entire element (reverse)', () => {
66
- const util = initUtil({ entireElement: true, entireEdge: false });
67
- expect(util.isNodeMarked(node)).is.equals(false);
68
- util.updateStartPoint({ x: 30, y: 50 });
69
- expect(util.isNodeMarked(node)).is.equals(false);
70
- util.updateStartPoint({ x: 250, y: 85 });
71
- expect(util.isNodeMarked(node)).is.equals(true);
72
- util.updateCurrentPoint({ x: 30, y: 85 });
73
- expect(util.isNodeMarked(node)).is.equals(false);
74
- });
75
- });
76
-
77
- describe('Edge marquee', () => {
78
- const edge = [
79
- { x: 20, y: 40 },
80
- { x: 40, y: 20 }
81
- ];
82
- const edge2 = [
83
- { x: 20, y: 20 },
84
- { x: 40, y: 40 },
85
- { x: 50, y: 10 }
86
- ];
87
-
88
- it('touch edge', () => {
89
- const util = initUtil();
90
- expect(util.isEdgeMarked(edge)).is.equals(false);
91
- expect(util.isEdgeMarked(edge2)).is.equals(false);
92
- util.updateCurrentPoint({ x: 20, y: 20 });
93
- expect(util.isEdgeMarked(edge)).is.equals(false);
94
- expect(util.isEdgeMarked(edge2)).is.equals(true);
95
- util.updateCurrentPoint({ x: 30, y: 30 });
96
- expect(util.isEdgeMarked(edge)).is.equals(true);
97
- expect(util.isEdgeMarked(edge2)).is.equals(true);
98
- util.updateCurrentPoint({ x: 50, y: 50 });
99
- expect(util.isEdgeMarked(edge)).is.equals(true);
100
- expect(util.isEdgeMarked(edge2)).is.equals(true);
101
- util.updateStartPoint({ x: 25, y: 25 });
102
- expect(util.isEdgeMarked(edge)).is.equals(true);
103
- expect(util.isEdgeMarked(edge2)).is.equals(true);
104
- });
105
-
106
- it('touch edge (reverse)', () => {
107
- const util = initUtil();
108
- expect(util.isEdgeMarked(edge)).is.equals(false);
109
- expect(util.isEdgeMarked(edge2)).is.equals(false);
110
- util.updateStartPoint({ x: 20, y: 20 });
111
- expect(util.isEdgeMarked(edge)).is.equals(false);
112
- expect(util.isEdgeMarked(edge2)).is.equals(true);
113
- util.updateStartPoint({ x: 30, y: 30 });
114
- expect(util.isEdgeMarked(edge)).is.equals(true);
115
- expect(util.isEdgeMarked(edge2)).is.equals(true);
116
- util.updateStartPoint({ x: 50, y: 50 });
117
- expect(util.isEdgeMarked(edge)).is.equals(true);
118
- expect(util.isEdgeMarked(edge2)).is.equals(true);
119
- util.updateCurrentPoint({ x: 25, y: 25 });
120
- expect(util.isEdgeMarked(edge)).is.equals(true);
121
- expect(util.isEdgeMarked(edge2)).is.equals(true);
122
- });
123
-
124
- it('mark entire edge', () => {
125
- const util = initUtil({ entireElement: false, entireEdge: true });
126
- expect(util.isEdgeMarked(edge)).is.equals(false);
127
- expect(util.isEdgeMarked(edge2)).is.equals(false);
128
- util.updateCurrentPoint({ x: 20, y: 20 });
129
- expect(util.isEdgeMarked(edge)).is.equals(false);
130
- expect(util.isEdgeMarked(edge2)).is.equals(false);
131
- util.updateCurrentPoint({ x: 30, y: 30 });
132
- expect(util.isEdgeMarked(edge)).is.equals(false);
133
- expect(util.isEdgeMarked(edge2)).is.equals(false);
134
- util.updateCurrentPoint({ x: 45, y: 50 });
135
- expect(util.isEdgeMarked(edge)).is.equals(true);
136
- expect(util.isEdgeMarked(edge2)).is.equals(false);
137
- util.updateCurrentPoint({ x: 55, y: 50 });
138
- expect(util.isEdgeMarked(edge)).is.equals(true);
139
- expect(util.isEdgeMarked(edge2)).is.equals(true);
140
- util.updateStartPoint({ x: 25, y: 25 });
141
- expect(util.isEdgeMarked(edge)).is.equals(false);
142
- expect(util.isEdgeMarked(edge2)).is.equals(false);
143
- });
144
-
145
- it('mark entire edge (reverse)', () => {
146
- const util = initUtil({ entireElement: false, entireEdge: true });
147
- expect(util.isEdgeMarked(edge)).is.equals(false);
148
- expect(util.isEdgeMarked(edge2)).is.equals(false);
149
- util.updateStartPoint({ x: 20, y: 20 });
150
- expect(util.isEdgeMarked(edge)).is.equals(false);
151
- expect(util.isEdgeMarked(edge2)).is.equals(false);
152
- util.updateStartPoint({ x: 30, y: 30 });
153
- expect(util.isEdgeMarked(edge)).is.equals(false);
154
- expect(util.isEdgeMarked(edge2)).is.equals(false);
155
- util.updateStartPoint({ x: 45, y: 50 });
156
- expect(util.isEdgeMarked(edge)).is.equals(true);
157
- expect(util.isEdgeMarked(edge2)).is.equals(false);
158
- util.updateStartPoint({ x: 55, y: 50 });
159
- expect(util.isEdgeMarked(edge)).is.equals(true);
160
- expect(util.isEdgeMarked(edge2)).is.equals(true);
161
- util.updateCurrentPoint({ x: 25, y: 25 });
162
- expect(util.isEdgeMarked(edge)).is.equals(false);
163
- expect(util.isEdgeMarked(edge2)).is.equals(false);
164
- });
165
-
166
- it('edge path should be marked', () => {
167
- const path = 'M 599.968775008469,272.3972942960205 L 677.0904664855072,232';
168
- const util = initUtil({ entireElement: false, entireEdge: true });
169
- expect(util.isEdgePathMarked(path)).is.equals(false);
170
- util.updateCurrentPoint({ x: 600, y: 300 });
171
- expect(util.isEdgePathMarked(path)).is.equals(false);
172
- util.updateCurrentPoint({ x: 700, y: 300 });
173
- expect(util.isEdgePathMarked(path)).is.equals(true);
174
- });
175
- });
176
- });
@@ -1,183 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2020-2023 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import { BoundsAware, GChildElement, GIssue, GModelElement, GModelRoot, GNode, GParentElement } from '@eclipse-glsp/sprotty';
17
- import { expect } from 'chai';
18
- import { Container } from 'inversify';
19
- import 'mocha';
20
- import 'reflect-metadata';
21
- import { defaultModule } from '../../base/default.module';
22
- import { GGraph } from '../../model';
23
- import { decorationModule } from '../decoration/decoration-module';
24
- import { GIssueMarker } from './issue-marker';
25
- import { MarkerNavigator } from './marker-navigator';
26
- import { markerNavigatorModule } from './validation-modules';
27
-
28
- describe('MarkerNavigator', () => {
29
- const container = new Container();
30
- container.load(defaultModule, decorationModule, markerNavigatorModule);
31
- const markerNavigator = container.get<MarkerNavigator>(MarkerNavigator);
32
- function createRoot(...nodeIds: string[]): GModelRoot {
33
- const root = new GGraph();
34
- root.features = new Set<symbol>(GGraph.DEFAULT_FEATURES);
35
- root.id = 'root';
36
- root.type = 'graph';
37
- nodeIds.forEach(id => {
38
- const node = new GNode();
39
- node.id = id;
40
- node.type = 'node';
41
- node.features = new Set<symbol>(GNode.DEFAULT_FEATURES);
42
- root.add(node);
43
- });
44
- return root;
45
- }
46
-
47
- const rootWithoutAnyMarkers = createRoot('1');
48
-
49
- const rootWithMarkers = createRoot('bottom-right', 'top-right', 'top-left', 'bottom-left');
50
-
51
- const elementTopLeft = rootWithMarkers.children[2] as BoundsAware & GChildElement;
52
- elementTopLeft.bounds = { width: 10, height: 10, x: 100, y: 100 };
53
- const elementTopRight = rootWithMarkers.children[1] as BoundsAware & GChildElement;
54
- elementTopRight.bounds = { width: 10, height: 10, x: 200, y: 100 };
55
- const elementBottomLeft = rootWithMarkers.children[3] as BoundsAware & GChildElement;
56
- elementBottomLeft.bounds = { width: 10, height: 10, x: 100, y: 200 };
57
- const elementBottomRight = rootWithMarkers.children[0] as BoundsAware & GChildElement;
58
- elementBottomRight.bounds = { width: 10, height: 10, x: 200, y: 200 };
59
-
60
- beforeEach('clear issue marker', () => {
61
- [elementTopLeft, elementTopRight, elementBottomLeft, elementBottomRight].forEach(clearMarker);
62
- });
63
-
64
- it('next(undefined) without any markers returns undefined', () => {
65
- expect(markerNavigator.next(rootWithoutAnyMarkers)).to.be.undefined;
66
- });
67
-
68
- it('previous(undefined) without any markers returns undefined', () => {
69
- expect(markerNavigator.previous(rootWithoutAnyMarkers)).to.be.undefined;
70
- });
71
-
72
- it('next(undefined) with one marker returns the one marker', () => {
73
- const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
74
- const next = markerNavigator.next(rootWithMarkers);
75
- expect(next).to.eql(marker);
76
- });
77
-
78
- it('next(firstMarker) with only one marker returns again the first marker', () => {
79
- const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
80
- const next = markerNavigator.next(rootWithMarkers, marker);
81
- expect(next).to.eql(marker);
82
- // and again and again
83
- const nextNext = markerNavigator.next(rootWithMarkers, next);
84
- expect(nextNext).to.eql(marker);
85
- });
86
-
87
- it('previous(firstMarker) with only one marker returns again the first marker', () => {
88
- const marker = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
89
- const previous = markerNavigator.previous(rootWithMarkers, marker);
90
- expect(previous).to.eql(marker);
91
- // and again and again
92
- const previousPrevious = markerNavigator.previous(rootWithMarkers, previous);
93
- expect(previousPrevious).to.eql(marker);
94
- });
95
-
96
- it('next(firstMarker) with two marker returns second marker then again first marker', () => {
97
- const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
98
- const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
99
- const next = markerNavigator.next(rootWithMarkers, marker1);
100
- expect(next).to.eql(marker2);
101
- // and again and again
102
- const nextNext = markerNavigator.next(rootWithMarkers, next);
103
- expect(nextNext).to.eql(marker1);
104
- });
105
-
106
- it('previous(firstMarker) with two marker returns second marker then again first marker', () => {
107
- const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
108
- const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
109
- const next = markerNavigator.previous(rootWithMarkers, marker1);
110
- expect(next).to.eql(marker2);
111
- // and again and again
112
- const nextNext = markerNavigator.previous(rootWithMarkers, next);
113
- expect(nextNext).to.eql(marker1);
114
- });
115
-
116
- it('returns markers in the order left-to-right, top-to-bottom with next()', () => {
117
- const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
118
- const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
119
- const marker3 = setIssues(elementBottomLeft, [{ message: 'msg', severity: 'error' }]);
120
- const marker4 = setIssues(elementBottomRight, [{ message: 'msg', severity: 'error' }]);
121
- const found1 = markerNavigator.next(rootWithMarkers);
122
- const found2 = markerNavigator.next(rootWithMarkers, found1);
123
- const found3 = markerNavigator.next(rootWithMarkers, found2);
124
- const found4 = markerNavigator.next(rootWithMarkers, found3);
125
- const found5 = markerNavigator.next(rootWithMarkers, found4);
126
- expect(found1).to.eql(marker1);
127
- expect(found2).to.eql(marker2);
128
- expect(found3).to.eql(marker3);
129
- expect(found4).to.eql(marker4);
130
- expect(found5).to.eql(marker1);
131
- });
132
-
133
- it('returns markers in the order left-to-right, top-to-bottom with previous()', () => {
134
- const marker1 = setIssues(elementTopLeft, [{ message: 'msg', severity: 'error' }]);
135
- const marker2 = setIssues(elementTopRight, [{ message: 'msg', severity: 'error' }]);
136
- const marker3 = setIssues(elementBottomLeft, [{ message: 'msg', severity: 'error' }]);
137
- const marker4 = setIssues(elementBottomRight, [{ message: 'msg', severity: 'error' }]);
138
- const found1 = markerNavigator.previous(rootWithMarkers);
139
- const found2 = markerNavigator.previous(rootWithMarkers, found1);
140
- const found3 = markerNavigator.previous(rootWithMarkers, found2);
141
- const found4 = markerNavigator.previous(rootWithMarkers, found3);
142
- const found5 = markerNavigator.previous(rootWithMarkers, found4);
143
- expect(found1).to.eql(marker1);
144
- expect(found2).to.eql(marker4);
145
- expect(found3).to.eql(marker3);
146
- expect(found4).to.eql(marker2);
147
- expect(found5).to.eql(marker1);
148
- });
149
- });
150
-
151
- function clearMarker(elem: GParentElement): void {
152
- elem.children.filter(isMarker).forEach(marker => elem.remove(marker));
153
- }
154
-
155
- function setIssues(elem: GParentElement, issues: GIssue[]): GIssueMarker {
156
- const marker = getOrCreateMarker(elem);
157
- marker.issues = issues;
158
- return marker;
159
- }
160
-
161
- function getOrCreateMarker(elem: GParentElement): GIssueMarker {
162
- const marker = findMarker(elem);
163
- if (marker instanceof GIssueMarker) {
164
- return marker;
165
- }
166
- return createMarker(elem as GParentElement);
167
- }
168
-
169
- function findMarker(elem: GParentElement): GIssueMarker | undefined {
170
- return elem.children.find(isMarker);
171
- }
172
-
173
- function isMarker(element: GModelElement): element is GIssueMarker {
174
- return element instanceof GIssueMarker;
175
- }
176
-
177
- function createMarker(elem: GParentElement): GIssueMarker {
178
- const newMarker = new GIssueMarker();
179
- newMarker.type = 'marker';
180
- newMarker.id = `${elem.id}_marker`;
181
- elem.add(newMarker);
182
- return newMarker;
183
- }
@@ -1,221 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2023 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import {
17
- AbstractEdgeRouter,
18
- EdgeRouterRegistry,
19
- GNode,
20
- GRoutableElement,
21
- GRoutingHandle,
22
- LinearRouteOptions,
23
- Point,
24
- ResolvedHandleMove,
25
- RoutedPoint
26
- } from '@eclipse-glsp/sprotty';
27
- import { expect } from 'chai';
28
- import { Container } from 'inversify';
29
- import { routingModule } from '../features/routing/routing-module';
30
- import { ALL_ROUTING_POINTS, ROUTE_KINDS, ROUTING_POINT_KINDS, calcRoute } from './gmodel-util';
31
- import { GEdge, GGraph } from '../model';
32
-
33
- class TestRouter extends AbstractEdgeRouter {
34
- kind = 'test-router';
35
-
36
- route(edge: GRoutableElement): RoutedPoint[] {
37
- const pureRoute = edge.routingPoints.map(
38
- (point, idx) =>
39
- <RoutedPoint>{
40
- kind: 'linear',
41
- ...point,
42
- pointIndex: idx
43
- }
44
- );
45
- return [
46
- { kind: 'source', ...edge.source!.position },
47
- ...pureRoute,
48
- { kind: 'bezier-control-after', x: 999, y: 999, pointIndex: pureRoute.length },
49
- { kind: 'target', ...edge.target!.position }
50
- ];
51
- }
52
-
53
- createRoutingHandles(edge: GRoutableElement): void {
54
- // do nothing
55
- }
56
-
57
- protected getOptions(edge: GRoutableElement): LinearRouteOptions {
58
- return {
59
- minimalPointDistance: 0,
60
- selfEdgeOffset: 0,
61
- standardDistance: 0
62
- };
63
- }
64
-
65
- protected getInnerHandlePosition(edge: GRoutableElement, route: RoutedPoint[], handle: GRoutingHandle): Point | undefined {
66
- return undefined;
67
- }
68
-
69
- protected applyInnerHandleMoves(edge: GRoutableElement, moves: ResolvedHandleMove[]): void {
70
- // do nothing
71
- }
72
- }
73
-
74
- describe('SModel Util', () => {
75
- describe('calcRoute', () => {
76
- const graph = new GGraph();
77
-
78
- const source = new GNode();
79
- source.id = 'node0';
80
- source.position = { x: 0, y: 0 };
81
- source.size = { width: 0, height: 0 };
82
- graph.add(source);
83
-
84
- const target = new GNode();
85
- target.id = 'node1';
86
- target.position = { x: 100, y: 100 };
87
- target.size = { width: 0, height: 0 };
88
- graph.add(target);
89
-
90
- const edge = new GEdge();
91
- edge.id = 'edge0';
92
- edge.sourceId = 'node0';
93
- edge.targetId = 'node1';
94
- graph.add(edge);
95
-
96
- edge.routerKind = 'test-router';
97
-
98
- const container = new Container();
99
- container.load(routingModule);
100
-
101
- const routerRegistry = container.get<EdgeRouterRegistry>(EdgeRouterRegistry);
102
- routerRegistry.register('test-router', new TestRouter());
103
-
104
- it('should return complete route', () => {
105
- edge.source!.position = { x: 0, y: 0 };
106
- edge.target!.position = { x: 100, y: 100 };
107
- edge.routingPoints = [
108
- { x: 20, y: 20 },
109
- { x: 30, y: 30 },
110
- { x: 40, y: 40 }
111
- ];
112
- const route = calcRoute(edge, routerRegistry);
113
- expect(route).to.deep.equal(<RoutedPoint[]>[
114
- { x: 0, y: 0, kind: 'source' },
115
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
116
- { x: 30, y: 30, kind: 'linear', pointIndex: 1 },
117
- { x: 40, y: 40, kind: 'linear', pointIndex: 2 },
118
- { x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
119
- { x: 100, y: 100, kind: 'target' }
120
- ]);
121
- });
122
-
123
- it('should filter duplicates with same coordinates', () => {
124
- edge.source!.position = { x: 0, y: 0 };
125
- edge.target!.position = { x: 100, y: 100 };
126
- edge.routingPoints = [
127
- { x: 20, y: 20 },
128
- { x: 20, y: 20 },
129
- { x: 30, y: 30 },
130
- { x: 40, y: 40 }
131
- ];
132
-
133
- const route = calcRoute(edge, routerRegistry);
134
- expect(route).to.deep.equal(<RoutedPoint[]>[
135
- { x: 0, y: 0, kind: 'source' },
136
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
137
- { x: 30, y: 30, kind: 'linear', pointIndex: 2 },
138
- { x: 40, y: 40, kind: 'linear', pointIndex: 3 },
139
- { x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
140
- { x: 100, y: 100, kind: 'target' }
141
- ]);
142
- });
143
-
144
- it('should not filter source and target even if duplicate coordinates', () => {
145
- edge.source!.position = { x: 0, y: 0 };
146
- edge.target!.position = { x: 0, y: 0 };
147
- edge.routingPoints = [
148
- { x: 20, y: 20 },
149
- { x: 30, y: 30 },
150
- { x: 40, y: 40 }
151
- ];
152
-
153
- const route = calcRoute(edge, routerRegistry);
154
- expect(route).to.deep.equal(<RoutedPoint[]>[
155
- { x: 0, y: 0, kind: 'source' },
156
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
157
- { x: 30, y: 30, kind: 'linear', pointIndex: 1 },
158
- { x: 40, y: 40, kind: 'linear', pointIndex: 2 },
159
- { x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 3 },
160
- { x: 0, y: 0, kind: 'target' }
161
- ]);
162
- });
163
-
164
- it('should filter duplicates with same coordinates but allow tolerance', () => {
165
- edge.source!.position = { x: 0, y: 0 };
166
- edge.target!.position = { x: 100, y: 100 };
167
- edge.routingPoints = [
168
- { x: 20, y: 20 },
169
- { x: 25, y: 25 },
170
- { x: 30, y: 30 },
171
- { x: 40, y: 40 }
172
- ];
173
-
174
- const route = calcRoute(edge, routerRegistry, ALL_ROUTING_POINTS, 10);
175
- expect(route).to.deep.equal(<RoutedPoint[]>[
176
- { x: 0, y: 0, kind: 'source' },
177
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
178
- { x: 30, y: 30, kind: 'linear', pointIndex: 2 },
179
- { x: 40, y: 40, kind: 'linear', pointIndex: 3 },
180
- { x: 999, y: 999, kind: 'bezier-control-after', pointIndex: 4 },
181
- { x: 100, y: 100, kind: 'target' }
182
- ]);
183
- });
184
-
185
- it('should allow filtering based on point type: ROUTE_KINDS', () => {
186
- edge.source!.position = { x: 0, y: 0 };
187
- edge.target!.position = { x: 100, y: 100 };
188
- edge.routingPoints = [
189
- { x: 20, y: 20 },
190
- { x: 30, y: 30 },
191
- { x: 40, y: 40 }
192
- ];
193
-
194
- const route = calcRoute(edge, routerRegistry, ROUTE_KINDS);
195
- expect(route).to.deep.equal(<RoutedPoint[]>[
196
- { x: 0, y: 0, kind: 'source' },
197
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
198
- { x: 30, y: 30, kind: 'linear', pointIndex: 1 },
199
- { x: 40, y: 40, kind: 'linear', pointIndex: 2 },
200
- { x: 100, y: 100, kind: 'target' }
201
- ]);
202
- });
203
-
204
- it('should allow filtering based on point type: ROUTING_POINT_KINDS', () => {
205
- edge.source!.position = { x: 0, y: 0 };
206
- edge.target!.position = { x: 100, y: 100 };
207
- edge.routingPoints = [
208
- { x: 20, y: 20 },
209
- { x: 30, y: 30 },
210
- { x: 40, y: 40 }
211
- ];
212
-
213
- const route = calcRoute(edge, routerRegistry, ROUTING_POINT_KINDS);
214
- expect(route).to.deep.equal(<RoutedPoint[]>[
215
- { x: 20, y: 20, kind: 'linear', pointIndex: 0 },
216
- { x: 30, y: 30, kind: 'linear', pointIndex: 1 },
217
- { x: 40, y: 40, kind: 'linear', pointIndex: 2 }
218
- ]);
219
- });
220
- });
221
- });