test(ResizeShape): add test coverage

* Restructure tests to make them more clear
* Add tests for businessObject updates (especially groups)
This commit is contained in:
Niklas Kiefer 2019-05-02 15:27:43 +02:00
parent 175e395768
commit 883d6c8ad3
2 changed files with 89 additions and 30 deletions

View File

@ -13,6 +13,7 @@
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="SubProcess_1" targetRef="EndEvent_1" />
<bpmn:group id="Group_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
@ -45,6 +46,9 @@
<dc:Bounds x="710" y="232" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Group_1_di" bpmnElement="Group_1">
<dc:Bounds x="264" y="42" width="500" height="400" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -3,6 +3,10 @@ import {
inject
} from 'test/TestHelper';
import {
getBusinessObject
} from 'lib/util/ModelUtil';
import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';
@ -18,53 +22,104 @@ describe('features/modeling - resize shape', function() {
describe('shape', function() {
it('should resize', inject(function(elementRegistry, modeling, bpmnFactory) {
it('should resize', inject(function(elementRegistry, modeling) {
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
var subProcessElement = elementRegistry.get('SubProcess_1'),
originalWidth = subProcessElement.width;
// when
// Decreasing width by 100px
modeling.resizeShape(subProcessElement, { x: 339, y: 142, width: 250, height: 200 });
// then
expect(subProcessElement.width).to.equal(250);
expect(subProcessElement.width).to.not.equal(originalWidth);
// expect flow layout
var diWaypoints = bpmnFactory.createDiWaypoints([
{ x: 589, y: 242 },
{ x: 821, y: 242 }
]);
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
}));
it('should move', inject(function(elementRegistry, modeling, bpmnFactory) {
describe('businessObject', function() {
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
it('should update bounds', inject(function(elementRegistry, modeling) {
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
// when
modeling.moveShape(subProcessElement, { x: -50, y: 0 });
// when
modeling.resizeShape(subProcessElement, { x: 339, y: 142, width: 250, height: 200 });
// then
// then
var bo = getBusinessObject(subProcessElement);
expect(bo.di.bounds.width).to.equal(250);
}));
// expect flow layout
var diWaypoints = bpmnFactory.createDiWaypoints([
{ x: 639, y: 242 },
{ x: 821, y: 242 }
]);
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
}));
it('should update group bounds', inject(function(elementRegistry, modeling) {
// given
var subProcessElement = elementRegistry.get('Group_1');
// when
modeling.resizeShape(subProcessElement, { x: 250, y: 250, width: 550, height: 400 });
// then
var bo = getBusinessObject(subProcessElement);
expect(bo.di.bounds.width).to.equal(550);
}));
});
describe('connected flow', function() {
it('should resize', inject(function(elementRegistry, modeling, bpmnFactory) {
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
// when
// Decreasing width by 100px
modeling.resizeShape(subProcessElement, { x: 339, y: 142, width: 250, height: 200 });
// then
// expect flow layout
var diWaypoints = bpmnFactory.createDiWaypoints([
{ x: 589, y: 242 },
{ x: 821, y: 242 }
]);
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
}));
it('should move', inject(function(elementRegistry, modeling, bpmnFactory) {
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
// when
modeling.moveShape(subProcessElement, { x: -50, y: 0 });
// then
// expect flow layout
var diWaypoints = bpmnFactory.createDiWaypoints([
{ x: 639, y: 242 },
{ x: 821, y: 242 }
]);
expect(sequenceFlow.di.waypoint).eql(diWaypoints);
}));
});
});