2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-10-09 23:40:52 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
pick
|
|
|
|
} from 'min-dash';
|
2015-10-09 23:40:52 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2015-10-09 23:40:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - delete lane', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./lanes.bpmn');
|
|
|
|
|
|
|
|
var testModules = [ coreModule, modelingModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
it('should remove first Lane', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var laneShape = elementRegistry.get('Lane_A'),
|
|
|
|
belowLaneShape = elementRegistry.get('Lane_B'),
|
|
|
|
belowLaneBounds = getBounds(belowLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(laneShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(belowLaneShape).to.have.bounds({
|
|
|
|
x: belowLaneBounds.x,
|
|
|
|
y: belowLaneBounds.y - laneShape.height,
|
|
|
|
width: belowLaneBounds.width,
|
|
|
|
height: belowLaneBounds.height + laneShape.height
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should remove last Lane', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var laneShape = elementRegistry.get('Lane_B'),
|
|
|
|
aboveLaneShape = elementRegistry.get('Lane_A'),
|
|
|
|
aboveLaneBounds = getBounds(aboveLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(laneShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(aboveLaneShape).to.have.bounds({
|
|
|
|
x: aboveLaneBounds.x,
|
|
|
|
y: aboveLaneBounds.y,
|
|
|
|
width: aboveLaneShape.width,
|
|
|
|
height: aboveLaneBounds.height + laneShape.height
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
describe('three lanes', function() {
|
|
|
|
|
|
|
|
it('should remove middle Lane', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var laneShape = elementRegistry.get('Nested_Lane_B'),
|
|
|
|
aboveLaneShape = elementRegistry.get('Nested_Lane_A'),
|
|
|
|
aboveLaneBounds = getBounds(aboveLaneShape),
|
|
|
|
belowLaneShape = elementRegistry.get('Nested_Lane_C'),
|
|
|
|
belowLaneBounds = getBounds(belowLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(laneShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(aboveLaneShape).to.have.bounds({
|
|
|
|
x: aboveLaneBounds.x,
|
|
|
|
y: aboveLaneBounds.y,
|
|
|
|
width: aboveLaneShape.width,
|
|
|
|
height: aboveLaneBounds.height + laneShape.height / 2
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(belowLaneShape).to.have.bounds({
|
|
|
|
x: belowLaneBounds.x,
|
|
|
|
y: belowLaneBounds.y - laneShape.height / 2,
|
|
|
|
width: belowLaneBounds.width,
|
|
|
|
height: belowLaneBounds.height + laneShape.height / 2
|
|
|
|
});
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should remove first Lane', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var laneShape = elementRegistry.get('Nested_Lane_A'),
|
|
|
|
belowLaneShape = elementRegistry.get('Nested_Lane_B'),
|
|
|
|
belowLaneBounds = getBounds(belowLaneShape),
|
|
|
|
lastLaneShape = elementRegistry.get('Nested_Lane_C'),
|
|
|
|
lastLaneBounds = getBounds(lastLaneShape);
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeShape(laneShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(belowLaneShape).to.have.bounds({
|
|
|
|
x: belowLaneBounds.x,
|
|
|
|
y: belowLaneBounds.y - laneShape.height,
|
|
|
|
width: belowLaneBounds.width,
|
|
|
|
height: belowLaneBounds.height + laneShape.height
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(lastLaneShape).to.have.bounds(lastLaneBounds);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// helpers ///////////////
|
|
|
|
|
|
|
|
function getBounds(element) {
|
|
|
|
return pick(element, [ 'x', 'y', 'width', 'height' ]);
|
|
|
|
}
|