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,6 +22,55 @@ describe('features/modeling - resize shape', function() {
describe('shape', function() {
it('should resize', inject(function(elementRegistry, modeling) {
// given
var subProcessElement = elementRegistry.get('SubProcess_1'),
originalWidth = subProcessElement.width;
// when
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);
}));
describe('businessObject', function() {
it('should update bounds', inject(function(elementRegistry, modeling) {
// given
var subProcessElement = elementRegistry.get('SubProcess_1');
// when
modeling.resizeShape(subProcessElement, { x: 339, y: 142, width: 250, height: 200 });
// then
var bo = getBusinessObject(subProcessElement);
expect(bo.di.bounds.width).to.equal(250);
}));
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) {
@ -69,3 +122,5 @@ describe('features/modeling - resize shape', function() {
});
});
});