2014-08-28 14:17:55 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Matchers = require('../../../Matchers'),
|
|
|
|
TestHelper = require('../../../TestHelper');
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
2014-10-30 11:06:43 +00:00
|
|
|
coreModule = require('../../../../lib/core');
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - move connection', function() {
|
|
|
|
|
|
|
|
beforeEach(Matchers.addDeepEquals);
|
|
|
|
|
|
|
|
|
2014-11-20 11:56:39 +00:00
|
|
|
var diagramXML = fs.readFileSync('test/fixtures/bpmn/sequence-flows.bpmn', 'utf8');
|
2014-08-28 14:17:55 +00:00
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
2014-08-28 14:17:55 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('connection handling', function() {
|
|
|
|
|
|
|
|
it('should execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
|
|
|
// expect cropped connection
|
|
|
|
expect(sequenceFlowConnection.waypoints).toDeepEqual([
|
|
|
|
{ x: 598, y: 351 },
|
|
|
|
{ x: 954, y: 351 },
|
|
|
|
{ x: 954, y: 446 },
|
|
|
|
{ x: 852, y: 446 }
|
|
|
|
]);
|
|
|
|
|
|
|
|
// expect cropped waypoints in di
|
|
|
|
expect(sequenceFlow.di.waypoint).toDeepEqual([
|
|
|
|
{ $type: 'dc:Point', x: 598, y: 351 },
|
|
|
|
{ $type: 'dc:Point', x: 954, y: 351 },
|
|
|
|
{ $type: 'dc:Point', x: 954, y: 446 },
|
|
|
|
{ $type: 'dc:Point', x: 852, y: 446 }
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('undo support', function() {
|
|
|
|
|
|
|
|
it('should undo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
var oldWaypoints = sequenceFlowConnection.waypoints,
|
|
|
|
oldDiWaypoints = sequenceFlow.di.waypoint;
|
|
|
|
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlowConnection.waypoints).toDeepEqual(oldWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).toDeepEqual(oldDiWaypoints);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('redo support', function() {
|
|
|
|
|
|
|
|
it('should redo', inject(function(elementRegistry, commandStack, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowConnection = elementRegistry.get('SequenceFlow_1'),
|
2014-08-28 14:17:55 +00:00
|
|
|
sequenceFlow = sequenceFlowConnection.businessObject;
|
|
|
|
|
|
|
|
modeling.moveConnection(sequenceFlowConnection, { x: 20, y: 10 });
|
|
|
|
|
|
|
|
var newWaypoints = sequenceFlowConnection.waypoints,
|
|
|
|
newDiWaypoints = sequenceFlow.di.waypoint;
|
|
|
|
|
|
|
|
// when
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlowConnection.waypoints).toDeepEqual(newWaypoints);
|
|
|
|
expect(sequenceFlow.di.waypoint).toDeepEqual(newDiWaypoints);
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|