123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977 |
- /* global sinon */
- import {
- bootstrapDiagram,
- inject
- } from 'test/TestHelper';
- import { createCanvasEvent as canvasEvent } from '../../../util/MockEvents';
- import bendpointsModule from 'lib/features/bendpoints';
- import modelingModule from 'lib/features/modeling';
- import selectModule from 'lib/features/selection';
- import CroppingConnectionDocking from 'lib/layout/CroppingConnectionDocking';
- var layoutModule = {
- connectionDocking: [ 'type', CroppingConnectionDocking ]
- };
- describe('features/bendpoints - segment move', function() {
- describe('should provide hints', function() {
- beforeEach(bootstrapDiagram({
- modules: [
- bendpointsModule,
- modelingModule,
- selectModule
- ]
- }));
- beforeEach(inject(function(dragging) {
- dragging.setOptions({ manual: true });
- }));
- var sourceShape, targetShape, connection;
- beforeEach(inject(function(elementFactory, canvas) {
- sourceShape = elementFactory.createShape({
- id: 'sourceShape', type: 'A',
- x: 100, y: 100,
- width: 200, height: 100
- });
- canvas.addShape(sourceShape);
- targetShape = elementFactory.createShape({
- id: 'targetShape', type: 'A',
- x: 600, y: 100,
- width: 100, height: 200
- });
- canvas.addShape(targetShape);
- }));
- it('basic', inject(function(canvas, connectionSegmentMove, dragging, eventBus, elementFactory) {
- // given
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 150 },
- { x: 200, y: 300 },
- { x: 600, y: 300 },
- { x: 600, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- var spy = sinon.spy(function(e) {
- expect(e.context.hints).to.have.property('segmentMove');
- });
- eventBus.once('commandStack.execute', spy);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
- dragging.move(canvasEvent({ x: 0, y: 50 }));
- dragging.end();
- // then
- expect(spy).to.have.been.called;
- }));
- it('remove start segment', inject(function(canvas, connectionSegmentMove, dragging, eventBus, elementFactory) {
- // given
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 150 },
- { x: 200, y: 300 },
- { x: 600, y: 300 },
- { x: 600, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- var spy = sinon.spy(function(e) {
- expect(e.context.hints.segmentMove).to.eql({
- segmentStartIndex: 1,
- newSegmentStartIndex: 0
- });
- });
- eventBus.once('commandStack.execute', spy);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: -150 }));
- dragging.end();
- // then
- expect(spy).to.have.been.called;
- }));
- describe('remove skewed segments', function() {
- it('start', inject(function(canvas, connectionSegmentMove, dragging, eventBus, elementFactory) {
- // given
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 150 },
- { x: 50, y: 400 },
- { x: 600, y: 400 },
- { x: 600, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- var spy = sinon.spy(function(e) {
- expect(e.context.hints).to.have.property('segmentMove');
- expect(e.context.hints.segmentMove.newSegmentStartIndex).to.eql(0);
- });
- eventBus.once('commandStack.execute', spy);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: -250 }));
- dragging.end();
- // then
- expect(spy).to.have.been.called;
- }));
- it('mid (one bendpoint removed)', inject(function(canvas, connectionSegmentMove, dragging, eventBus, elementFactory) {
- // given
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 150 },
- { x: 200, y: 400 },
- { x: 300, y: 300 },
- { x: 600, y: 300 },
- { x: 600, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- var spy = sinon.spy(function(e) {
- expect(e.context.hints).to.have.property('segmentMove');
- expect(e.context.hints.segmentMove.newSegmentStartIndex).to.eql(1);
- });
- eventBus.once('commandStack.execute', spy);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 3);
- dragging.move(canvasEvent({ x: 0, y: 100 }));
- dragging.end();
- // then
- expect(spy).to.have.been.called;
- }));
- it('mid (two bendpoints removed)', inject(function(canvas, connectionSegmentMove, dragging, eventBus, elementFactory) {
- // given
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 150 },
- { x: 200, y: 400 },
- { x: 250, y: 400 },
- { x: 300, y: 300 },
- { x: 600, y: 300 },
- { x: 600, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- var spy = sinon.spy(function(e) {
- expect(e.context.hints).to.have.property('segmentMove');
- expect(e.context.hints.segmentMove.newSegmentStartIndex).to.eql(1);
- });
- eventBus.once('commandStack.execute', spy);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 4);
- dragging.move(canvasEvent({ x: 0, y: 100 }));
- dragging.end();
- // then
- expect(spy).to.have.been.called;
- }));
- });
- });
- describe('without docking', function() {
- beforeEach(bootstrapDiagram({
- modules: [
- bendpointsModule,
- modelingModule,
- selectModule
- ]
- }));
- beforeEach(inject(function(dragging) {
- dragging.setOptions({ manual: true });
- }));
- var sourceShape, targetShape, connection;
- beforeEach(inject(function(elementFactory, canvas) {
- sourceShape = elementFactory.createShape({
- id: 'sourceShape', type: 'A',
- x: 100, y: 400,
- width: 200, height: 100
- });
- canvas.addShape(sourceShape);
- targetShape = elementFactory.createShape({
- id: 'targetShape', type: 'A',
- x: 600, y: 50,
- width: 100, height: 200
- });
- canvas.addShape(targetShape);
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 200, y: 450 },
- { x: 400, y: 450 },
- { x: 400, y: 150 },
- { x: 650, y: 150 }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- }));
- it('should vertical move first segment',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // when
- connectionSegmentMove.start(canvasEvent({ x: 275, y: 450 }), connection, 1);
- dragging.move(canvasEvent({ x: 275, y: 430 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 200, y: 430 },
- { x: 400, y: 430 },
- { x: 400, y: 150 },
- { x: 650, y: 150 }
- ]);
- // not introducing a docking (!)
- expect(connection).to.have.startDocking(undefined);
- expect(connection).to.have.endDocking(undefined);
- })
- );
- it('should vertical move last segment',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // when
- connectionSegmentMove.start(canvasEvent({ x: 425, y: 150 }), connection, 3);
- dragging.move(canvasEvent({ x: 425, y: 210 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 200, y: 450 },
- { x: 400, y: 450 },
- { x: 400, y: 210 },
- { x: 650, y: 210 }
- ]);
- // not introducing a docking (!)
- expect(connection).to.have.startDocking(undefined);
- expect(connection).to.have.endDocking(undefined);
- })
- );
- it('should move mid segment beyond source',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // when
- // moving mid segment left of start shape
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 50, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 200, y: 450 },
- { x: 50, y: 450 },
- { x: 50, y: 150 },
- { x: 650, y: 150 }
- ]);
- })
- );
- it('should move mid segment beyond target',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 750, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 200, y: 450 },
- { x: 750, y: 450 },
- { x: 750, y: 150 },
- { x: 650, y: 150 }
- ]);
- })
- );
- it('should move mid segment, removing last',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 620, y: 200 }));
- dragging.end();
- // then
- expect(connection.waypoints[2].x).to.eql(620);
- })
- );
- it('should move mid segment, removing first',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 280, y: 200 }));
- dragging.end();
- // then
- expect(connection.waypoints[0].x).to.eql(280);
- expect(connection.waypoints.length).to.eql(3);
- })
- );
- // see issue #367
- it('should keep other axis',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given drag last intersection down a bit
- connectionSegmentMove.start(canvasEvent({ x: 425, y: 150 }), connection, 3);
- dragging.move(canvasEvent({ x: 425, y: 210 }));
- dragging.end();
- // when: middle intersection is dragged to the left
- // multiple steps are needed because it needs to pass the shape
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 300 }), connection, 2);
- dragging.move(canvasEvent({ x: 650, y: 300 }));
- dragging.move(canvasEvent({ x: 750, y: 300 }));
- dragging.end();
- // then: the y axis doesn't change (back to target center)
- expect(connection.waypoints[3].y).to.eql(210);
- })
- );
- it('should keep the start docking as long as needed',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- // connection.waypoint[0] === { x: 150, y: 450 }
- // when: dragging intersection out of the element
- connectionSegmentMove.start(canvasEvent({ x: 275, y: 450 }), connection, 1);
- dragging.move(canvasEvent({ x: 275, y: 350 }));
- dragging.end();
- })
- );
- it('should keep the end docking as long as needed',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- // connection.waypoints[last] === { x: 680, y: 150 }
- // when
- // dragging intersection out of the element
- connectionSegmentMove.start(canvasEvent({ x: 425, y: 150 }), connection, 3);
- dragging.move(canvasEvent({ x: 425, y: 300 }));
- dragging.end();
- })
- );
- });
- describe('with docking (via connectionDocking)', function() {
- beforeEach(bootstrapDiagram({
- modules: [
- bendpointsModule,
- modelingModule,
- selectModule,
- layoutModule
- ]
- }));
- beforeEach(inject(function(dragging) {
- dragging.setOptions({ manual: true });
- }));
- var sourceShape, targetShape, connection;
- beforeEach(inject(function(elementFactory, canvas) {
- sourceShape = elementFactory.createShape({
- id: 'sourceShape', type: 'A',
- x: 100, y: 400,
- width: 200, height: 100
- });
- canvas.addShape(sourceShape);
- targetShape = elementFactory.createShape({
- id: 'targetShape', type: 'A',
- x: 600, y: 50,
- width: 100, height: 200
- });
- canvas.addShape(targetShape);
- connection = elementFactory.createConnection({
- id: 'connection',
- waypoints: [
- { x: 300, y: 450, original: { x: 250, y: 450 } },
- { x: 400, y: 450 },
- { x: 400, y: 150 },
- { x: 600, y: 150, original: { x: 650, y: 150 } }
- ],
- source: sourceShape,
- target: targetShape
- });
- canvas.addConnection(connection);
- }));
- it('should vertical move first segment',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldEnd = connection.waypoints[3];
- // when
- connectionSegmentMove.start(canvasEvent({ x: 275, y: 450 }), connection, 1);
- dragging.move(canvasEvent({ x: 275, y: 430 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 300, y: 430 },
- { x: 400, y: 430 },
- { x: 400, y: 150 },
- { x: 600, y: 150 }
- ]);
- // updating start docking
- expect(connection).to.have.startDocking({ x: 250, y: 430 });
- expect(connection).to.have.endDocking(oldEnd.original);
- })
- );
- it('should vertical move last segment',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldStart = connection.waypoints[0];
- // when
- connectionSegmentMove.start(canvasEvent({ x: 425, y: 150 }), connection, 3);
- dragging.move(canvasEvent({ x: 425, y: 210 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 300, y: 450 },
- { x: 400, y: 450 },
- { x: 400, y: 210 },
- { x: 600, y: 210 }
- ]);
- // updating end docking
- expect(connection).to.have.startDocking(oldStart.original);
- expect(connection).to.have.endDocking({ x: 650, y: 210 });
- })
- );
- it('should move mid segment beyond source',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldEnd = connection.waypoints[3];
- // when
- // moving mid segment left of start shape
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 50, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 100, y: 450 },
- { x: 50, y: 450 },
- { x: 50, y: 150 },
- { x: 600, y: 150 }
- ]);
- // updating end docking
- expect(connection).to.have.startDocking({ x: 250, y: 450 });
- expect(connection).to.have.endDocking(oldEnd.original);
- })
- );
- it('should move mid segment beyond target',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldStart = connection.waypoints[0];
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 750, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 300, y: 450 },
- { x: 750, y: 450 },
- { x: 750, y: 150 },
- { x: 700, y: 150 }
- ]);
- // updating end docking
- expect(connection).to.have.startDocking(oldStart.original);
- expect(connection).to.have.endDocking({ x: 650, y: 150 });
- })
- );
- it('should move mid segment, removing last',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldStart = connection.waypoints[0];
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 620, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 300, y: 450 },
- { x: 620, y: 450 },
- { x: 620, y: 250 }
- ]);
- // updating end docking
- expect(connection).to.have.startDocking(oldStart.original);
- expect(connection).to.have.endDocking({ x: 620, y: 150 });
- })
- );
- it('should move mid segment, removing first',
- inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var oldEnd = connection.waypoints[3];
- // given drag middle to the left
- connectionSegmentMove.start(canvasEvent({ x: 400, y: 200 }), connection, 2);
- dragging.move(canvasEvent({ x: 280, y: 200 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 280, y: 400 },
- { x: 280, y: 150 },
- { x: 600, y: 150 }
- ]);
- // updating end docking
- expect(connection).to.have.startDocking({ x: 280, y: 450 });
- expect(connection).to.have.endDocking(oldEnd.original);
- })
- );
- });
- describe('width docking (skewed segments, no filteredWaypoints)', function() {
- beforeEach(bootstrapDiagram({
- modules: [
- bendpointsModule,
- modelingModule,
- selectModule,
- layoutModule
- ]
- }));
- beforeEach(inject(function(dragging) {
- dragging.setOptions({ manual: true });
- }));
- var sourceShape, targetShape, createConnection;
- beforeEach(inject(function(elementFactory, canvas) {
- sourceShape = elementFactory.createShape({
- id: 'sourceShape', type: 'A',
- x: 100, y: 100,
- width: 100, height: 100
- });
- canvas.addShape(sourceShape);
- targetShape = elementFactory.createShape({
- id: 'targetShape', type: 'A',
- x: 600, y: 100,
- width: 100, height: 100
- });
- canvas.addShape(targetShape);
- createConnection = function(waypoints) {
- return elementFactory.createConnection({
- id: 'connection',
- waypoints: waypoints,
- source: sourceShape,
- target: targetShape
- });
- };
- }));
- it('two skewed side segments', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 150 },
- { x: 50, y: 400 },
- { x: 750, y: 400 },
- { x: 650, y: 150 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: -250 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 200, y: 150 },
- { x: 600, y: 150 }
- ]);
- }));
- it('4 manhatten waypoints in the middle', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 300, y: 400 },
- { x: 300, y: 450 },
- { x: 500, y: 450 },
- { x: 500, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 4);
- dragging.move(canvasEvent({ x: 0, y: -50 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- }));
- it('4 waypoints in the middle, 2 skewed side-segments', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 300, y: 400 },
- { x: 350, y: 450 },
- { x: 450, y: 450 },
- { x: 500, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 4);
- dragging.move(canvasEvent({ x: 0, y: -50 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- }));
- it('2 waypoints in the middle with skewed segments', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 300, y: 300 },
- { x: 500, y: 300 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 3);
- dragging.move(canvasEvent({ x: 0, y: 100 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- }));
- it('two horizontal segment in the middle, in front of last segment', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 500, y: 400 },
- { x: 500, y: 450 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: 50 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 450 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- }));
- it('one skewed segment in the middle, in front of last segment', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 500, y: 400 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: 50 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 450 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- }));
- it('one skewed and one horizontal segment in the middle, in front of last segment', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 500, y: 400 },
- { x: 550, y: 450 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 0, y: 50 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 450 },
- { x: 650, y: 450 },
- { x: 650, y: 200 }
- ]);
- }));
- it('skewed segment on start', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 50, y: 300 },
- { x: 50, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
- dragging.move(canvasEvent({ x: 100, y: 0 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- }));
- it('skewed segment on end', inject(function(canvas, connectionSegmentMove, dragging) {
- // given
- var connection = createConnection([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 750, y: 400 },
- { x: 750, y: 250 },
- { x: 650, y: 200 }
- ]);
- canvas.addConnection(connection);
- // when
- connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 3);
- dragging.move(canvasEvent({ x: -100, y: 0 }));
- dragging.end();
- // then
- expect(connection).to.have.waypoints([
- { x: 150, y: 200 },
- { x: 150, y: 400 },
- { x: 650, y: 400 },
- { x: 650, y: 200 }
- ]);
- }));
- });
- });
|