fix(import): correctly import label DI

Related to #145
This commit is contained in:
Nico Rehwaldt 2014-10-30 12:07:28 +01:00
parent c58532aeac
commit 447086bbdf
3 changed files with 40 additions and 6 deletions

View File

@ -83,7 +83,7 @@ module.exports.getExternalLabelBounds = function(semantic, element) {
mid = {
x: bounds.x + bounds.width / 2,
y: bounds.y
y: bounds.y + bounds.height / 2
};
} else {

View File

@ -13,6 +13,9 @@
<bpmn2:sequenceFlow id="SequenceFlow_1" name="a sequence flow" sourceRef="StartEvent_1" targetRef="IntermediateThrowEvent_1"/>
<bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="a gateway"/>
<bpmn2:dataObjectReference id="DataObjectReference_1" name="a data object&#xD;&#xA;reference" dataObjectRef="DataObject_1"/>
<bpmn2:endEvent id="EndEvent_1" name="Loan Request&#xD;&#xA;Approved">
<bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:process>
<bpmn2:dataStore id="DataStore_1" name="Data Store 1"/>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
@ -56,6 +59,12 @@
<dc:Bounds height="22.0" width="99.0" x="432.0" y="317.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="252.0" y="215.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="44.0" width="119.0" x="211.0" y="256.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

View File

@ -1,17 +1,21 @@
'use strict';
var Matchers = require('../../../Matchers'),
TestHelper = require('../../../TestHelper');
var TestHelper = require('../../../TestHelper');
/* global bootstrapViewer, inject */
var _ = require('lodash');
var fs = require('fs');
describe('import - labels', function() {
function bounds(element) {
return _.pick(element, [ 'x', 'y', 'width', 'height' ]);
}
beforeEach(Matchers.addDeepEquals);
describe('import - labels', function() {
describe('should import embedded labels', function() {
@ -40,7 +44,28 @@ describe('import - labels', function() {
it('with di', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/external.bpmn', 'utf8');
bootstrapViewer(xml)(done);
// given
bootstrapViewer(xml)(function(err) {
if (err) {
return done(err);
}
// when
inject(function(elementRegistry) {
var endEvent = elementRegistry.getById('EndEvent_1'),
sequenceFlow = elementRegistry.getById('SequenceFlow_1');
// then
expect(bounds(endEvent.label)).toEqual({ x: 211, y: 256, width: 119, height: 44 });
expect(bounds(sequenceFlow.label)).toEqual({ x: 432, y: 317, width: 99, height: 22 });
done();
})();
});
});