Skip to content

Commit

Permalink
fix(label-behavior): properly check for name property change
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Jun 6, 2018
1 parent a3a597f commit 4a0f6da
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/features/modeling/behavior/LabelBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function LabelBehavior(
element = context.element,
properties = context.properties;

if (name in properties) {
modeling.updateLabel(element, name);
if ('name' in properties) {
modeling.updateLabel(element, properties.name);
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.1">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent_1" name="foo" />
<bpmn:task id="Task_1" />
<bpmn:exclusiveGateway id="ExclusiveGateway_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
Expand All @@ -15,6 +16,9 @@
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
<dc:Bounds x="353" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ExclusiveGateway_1gzwevj_di" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">
<dc:Bounds x="256" y="95" width="50" height="50" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
47 changes: 47 additions & 0 deletions test/spec/features/modeling/behavior/LabelBehaviorSpec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global sinon */

import {
bootstrapModeler,
inject
Expand All @@ -17,6 +19,51 @@ describe('behavior - LabelBehavior', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));


describe('updating name property', function() {

it('should update label', inject(function(elementRegistry, eventBus, modeling) {

// given
var startEvent = elementRegistry.get('StartEvent_1'),
spy = sinon.spy();

eventBus.once('commandStack.element.updateLabel.execute', spy);

// when
modeling.updateProperties(startEvent, {
name: 'bar'
});

// then
expect(startEvent.businessObject.name).to.equal('bar');
expect(spy).to.have.been.called;
}));


it('should create label', inject(function(elementRegistry, eventBus, modeling) {

// given
var startEvent = elementRegistry.get('ExclusiveGateway_1'),
spy = sinon.spy();

eventBus.once('commandStack.element.updateLabel.execute', spy);

// when
modeling.updateProperties(startEvent, {
name: 'foo'
});

// then
var labelShape = startEvent.label;

expect(labelShape).to.exist;
expect(startEvent.businessObject.name).to.equal('foo');
expect(spy).to.have.been.called;
}));

});


describe('add label', function() {

it('should add to sequence flow with name', inject(
Expand Down

0 comments on commit 4a0f6da

Please sign in to comment.