diff --git a/test/jointjs/routers.js b/test/jointjs/routers.js index 0d961f157c..c7a18dd7d5 100644 --- a/test/jointjs/routers.js +++ b/test/jointjs/routers.js @@ -818,12 +818,22 @@ QUnit.module('routers', function(hooks) { `${position.y + width} ${height / 2}` ]; + const rightVerticalPathSegments = [ + `${width} ${height / 2}`, + `${width + margin} ${height / 2}`, + `${width + margin} ${height / 2 + position.y}`, + `${width} ${height / 2 + position.y}`, + ]; + QUnit.test('rightAngle routing - source: right, target: right', function(assert) { const [r1, r2, l] = this.addTestSubjects('right', 'right'); let d = this.paper.findViewByModel(l).metrics.data; + let segments = joint.util.cloneDeep(rightVerticalPathSegments); + let moveSegment = segments.shift(); + let path = `M ${moveSegment} L ${segments.join(' L ')}`; - assert.checkDataPath(d, 'M 50 25 L 78 25 L 78 25 L 78 25 L 78 175 L 50 175', 'Source above target'); + assert.checkDataPath(d, path, 'Source above target'); let position1 = r1.position(); let position2 = r2.position(); @@ -832,16 +842,19 @@ QUnit.module('routers', function(hooks) { r2.position(position1.x, position1.y); d = this.paper.findViewByModel(l).metrics.data; + segments = joint.util.cloneDeep(rightVerticalPathSegments).reverse(); + moveSegment = segments.shift(); + path = `M ${moveSegment} L ${segments.join(' L ')}`; - assert.checkDataPath(d, 'M 50 175 L 78 175 L 78 175 L 78 175 L 78 25 L 50 25', 'Target above source'); + assert.checkDataPath(d, path, 'Target above source'); r1.position(0, 0); r2.position(position.y, position.x); d = this.paper.findViewByModel(l).metrics.data; - let segments = joint.util.cloneDeep(rightHorizontalPathSegments); - let moveSegment = segments.shift(); - let path = `M ${moveSegment} L ${segments.join(' L ')}`; + segments = joint.util.cloneDeep(rightHorizontalPathSegments); + moveSegment = segments.shift(); + path = `M ${moveSegment} L ${segments.join(' L ')}`; assert.checkDataPath(d, path, 'Source on the left of target'); @@ -1405,12 +1418,22 @@ QUnit.module('routers', function(hooks) { `${position.y} ${height / 2}` ]; + const leftVerticalPathSegments = [ + `0 ${height / 2}`, + `-${margin} ${height / 2}`, + `-${margin} ${height / 2 + position.y}`, + `0 ${height / 2 + position.y}` + ]; + QUnit.test('rightAngle routing - source: left, target: left', function(assert) { const [r1, r2, l] = this.addTestSubjects('left', 'left'); let d = this.paper.findViewByModel(l).metrics.data; + let segments = joint.util.cloneDeep(leftVerticalPathSegments); + let moveSegment = segments.shift(); + let path = `M ${moveSegment} L ${segments.join(' L ')}`; - assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 25 L -28 25 L -28 175 L 0 175', 'Source above target'); + assert.checkDataPath(d, path, 'Source above target'); let position1 = r1.position(); let position2 = r2.position(); @@ -1419,16 +1442,19 @@ QUnit.module('routers', function(hooks) { r2.position(position1.x, position1.y); d = this.paper.findViewByModel(l).metrics.data; + segments = joint.util.cloneDeep(leftVerticalPathSegments).reverse(); + moveSegment = segments.shift(); + path = `M ${moveSegment} L ${segments.join(' L ')}`; - assert.checkDataPath(d, 'M 0 175 L -28 175 L -28 175 L -28 175 L -28 25 L 0 25', 'Target above source'); + assert.checkDataPath(d, path, 'Target above source'); r1.position(0, 0); r2.position(position.y, position.x); d = this.paper.findViewByModel(l).metrics.data; - let segments = joint.util.cloneDeep(leftHorizontalPathSegments); - let moveSegment = segments.shift(); - let path = `M ${moveSegment} L ${segments.join(' L ')}`; + segments = joint.util.cloneDeep(leftHorizontalPathSegments); + moveSegment = segments.shift(); + path = `M ${moveSegment} L ${segments.join(' L ')}`; assert.checkDataPath(d, path, 'Source on the left of target'); @@ -1505,7 +1531,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 0 L 25 -28 L -28 -28 L -28 100 L 125 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); + assert.checkDataPath(d, 'M 25 0 L 25 -28 L -28 -28 L -28 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); position1 = r1.position(); position2 = r2.position(); @@ -1560,7 +1586,7 @@ QUnit.module('routers', function(hooks) { let d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 0 L 25 -28 L 100 -28 L 100 100 L 75 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); + assert.checkDataPath(d, 'M 25 0 L 25 -28 L 100 -28 L 100 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); let position1 = r1.position(); let position2 = r2.position(); @@ -1570,7 +1596,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 150 L 25 125 L 100 125 L 100 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); + assert.checkDataPath(d, 'M 25 150 L 25 125 L 100 125 L 100 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); r1.position(0, 0); r2.position(position.y, position.x); @@ -1587,7 +1613,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 175 0 L 175 -28 L 228 -28 L 228 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); + assert.checkDataPath(d, 'M 175 0 L 175 -28 L 228 -28 L 228 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); }); QUnit.test('rightAngle routing with vertex - source: right, target: top', function(assert) { @@ -1596,7 +1622,7 @@ QUnit.module('routers', function(hooks) { let d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 50 25 L 78 25 L 78 25 L 100 25 L 100 100 L 25 100 L 25 150', 'Source above target with vertex'); + assert.checkDataPath(d, 'M 50 25 L 78 25 L 100 25 L 100 100 L 25 100 L 25 150', 'Source above target with vertex'); let position1 = r1.position(); let position2 = r2.position(); @@ -1649,7 +1675,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 50 25 L 89 25 L 89 100 L 125 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); + assert.checkDataPath(d, 'M 50 25 L 89 25 L 89 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); position1 = r1.position(); position2 = r2.position(); @@ -1678,7 +1704,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 50 175 L 78 175 L 78 175 L 100 175 L 100 100 L 25 100 L 25 50', 'Target above source with vertex'); + assert.checkDataPath(d, 'M 50 175 L 78 175 L 100 175 L 100 100 L 25 100 L 25 50', 'Target above source with vertex'); r1.position(0, 0); r2.position(position.y, position.x); @@ -1695,7 +1721,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 200 25 L 228 25 L 228 100 L 125 100 L 125 100 L 25 100 L 25 50', 'Target on the left of source with vertex'); + assert.checkDataPath(d, 'M 200 25 L 228 25 L 228 100 L 125 100 L 25 100 L 25 50', 'Target on the left of source with vertex'); }); QUnit.test('rightAngle routing with vertex - source: right, target: left', function(assert) { @@ -1705,7 +1731,7 @@ QUnit.module('routers', function(hooks) { let d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 50 25 L 78 25 L 78 25 L 100 25 L 100 100 L 75 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); + assert.checkDataPath(d, 'M 50 25 L 78 25 L 100 25 L 100 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); let position1 = r1.position(); let position2 = r2.position(); @@ -1715,7 +1741,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 50 175 L 78 175 L 78 175 L 100 175 L 100 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); + assert.checkDataPath(d, 'M 50 175 L 78 175 L 100 175 L 100 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); r1.position(0, 0); r2.position(position.y, position.x); @@ -1732,7 +1758,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 200 25 L 228 25 L 228 100 L 125 100 L 125 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); + assert.checkDataPath(d, 'M 200 25 L 228 25 L 228 100 L 125 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); }); QUnit.test('rightAngle routing with vertex - source: bottom, target: top', function(assert) { @@ -1794,7 +1820,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 50 L 25 100 L 125 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); + assert.checkDataPath(d, 'M 25 50 L 25 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); position1 = r1.position(); position2 = r2.position(); @@ -1849,7 +1875,7 @@ QUnit.module('routers', function(hooks) { let d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 50 L 25 75 L 100 75 L 100 100 L 75 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); + assert.checkDataPath(d, 'M 25 50 L 25 75 L 100 75 L 100 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); let position1 = r1.position(); let position2 = r2.position(); @@ -1859,7 +1885,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 25 200 L 25 228 L 100 228 L 100 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); + assert.checkDataPath(d, 'M 25 200 L 25 228 L 100 228 L 100 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); r1.position(0, 0); r2.position(position.y, position.x); @@ -1876,7 +1902,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 175 50 L 175 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); + assert.checkDataPath(d, 'M 175 50 L 175 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); }); QUnit.test('rightAngle routing with vertex - source: left, target: top', function(assert) { @@ -1938,7 +1964,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 100 L 75 100 L 75 100 L 125 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); + assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 100 L 75 100 L 125 100 L 228 100 L 228 25 L 200 25', 'Source on the left of target with vertex'); position1 = r1.position(); position2 = r2.position(); @@ -1974,7 +2000,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 100 L 75 100 L 75 100 L 175 100 L 175 50', 'Source on the left of target with vertex'); + assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 100 L 75 100 L 175 100 L 175 50', 'Source on the left of target with vertex'); position1 = r1.position(); position2 = r2.position(); @@ -1993,7 +2019,7 @@ QUnit.module('routers', function(hooks) { let d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 75 L 100 75 L 100 100 L 75 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); + assert.checkDataPath(d, 'M 0 25 L -28 25 L -28 75 L 100 75 L 100 100 L 75 100 L -28 100 L -28 175 L 0 175', 'Source above target with vertex'); let position1 = r1.position(); let position2 = r2.position(); @@ -2003,7 +2029,7 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 0 175 L -28 175 L -28 125 L 100 125 L 100 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); + assert.checkDataPath(d, 'M 0 175 L -28 175 L -28 125 L 100 125 L 100 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target above source with vertex'); r1.position(0, 0); r2.position(position.y, position.x); @@ -2020,6 +2046,6 @@ QUnit.module('routers', function(hooks) { d = this.paper.findViewByModel(l).metrics.data; - assert.checkDataPath(d, 'M 150 25 L 111 25 L 111 100 L 75 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); + assert.checkDataPath(d, 'M 150 25 L 111 25 L 111 100 L 75 100 L -28 100 L -28 25 L 0 25', 'Target on the left of source with vertex'); }); });