test(modeling): verify re-connect preview layout

This commit is contained in:
Maciej Barelkowski 2019-05-09 10:14:27 +02:00 committed by Philipp Fromme
parent 82dbcc9451
commit 654fa067d4
1 changed files with 64 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import coreModule from 'lib/core';
import connectModule from 'lib/features/connect';
import createModule from 'lib/features/create';
import bendpointsModule from 'diagram-js/lib/features/bendpoints';
import {
createCanvasEvent as canvasEvent
@ -23,7 +24,8 @@ describe('features/modeling - layout connection', function() {
coreModule,
modelingModule,
connectModule,
createModule
createModule,
bendpointsModule
]
}));
@ -193,7 +195,7 @@ describe('features/modeling - layout connection', function() {
}));
it('should correctly lay out append shape connection preview',
it('should correctly lay out connection preview on create',
inject(function(canvas, create, dragging, elementRegistry) {
// given
@ -260,6 +262,66 @@ describe('features/modeling - layout connection', function() {
expect(task1.outgoing[0].waypoints).to.deep.eql(waypointsPreview);
})
);
it('should correctly lay out connection preview on reconnect start',
inject(function(canvas, bendpointMove, dragging, elementRegistry) {
// given
var task1 = elementRegistry.get('Task_1'),
task1Gfx = canvas.getGraphics(task1),
sequenceFlow2 = elementRegistry.get('SequenceFlow_2');
// when
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), sequenceFlow2, 0);
dragging.move(canvasEvent({ x: 230, y: 360 }));
dragging.hover({ element: task1, gfx: task1Gfx });
dragging.move(canvasEvent({ x: 248, y: 382 }));
var ctx = dragging.context();
var context = ctx.data.context;
var connectionPreview = context.connection;
var waypointsPreview = connectionPreview.waypoints.slice();
dragging.end();
// then
expect(task1.outgoing[0]).to.exist;
expect(task1.outgoing[0].waypoints).to.deep.eql(waypointsPreview);
})
);
it('should correctly lay out connection preview on reconnect end',
inject(function(canvas, bendpointMove, dragging, elementRegistry) {
// given
var task1 = elementRegistry.get('Task_1'),
task1Gfx = canvas.getGraphics(task1),
sequenceFlow2 = elementRegistry.get('SequenceFlow_2');
// when
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), sequenceFlow2, 2);
dragging.move(canvasEvent({ x: 230, y: 360 }));
dragging.hover({ element: task1, gfx: task1Gfx });
dragging.move(canvasEvent({ x: 248, y: 382 }));
var ctx = dragging.context();
var context = ctx.data.context;
var connectionPreview = context.connection;
var waypointsPreview = connectionPreview.waypoints.slice();
dragging.end();
// then
expect(task1.incoming[0]).to.exist;
expect(task1.incoming[0].waypoints).to.deep.eql(waypointsPreview);
})
);
});
});