2016-10-28 15:42:42 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../../../TestHelper');
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
|
2018-01-24 10:41:21 +00:00
|
|
|
var modelingModule = require('lib/features/modeling'),
|
|
|
|
coreModule = require('lib/core');
|
2016-10-28 15:42:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features - bpmn-updater', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('./BpmnUpdater.bpmn');
|
|
|
|
|
|
|
|
var testModules = [ modelingModule, coreModule ];
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('connection di', function() {
|
|
|
|
|
|
|
|
it('should update after deleting intermediate element', inject(function(modeling, elementRegistry) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
// sequence flow with existing sourceElement and targetElement di information
|
|
|
|
var task = elementRegistry.get('Task_1'),
|
|
|
|
sequenceFlowDi = elementRegistry.get('SequenceFlow_1').businessObject.di,
|
|
|
|
startEventDi = elementRegistry.get('StartEvent_1').businessObject.di,
|
|
|
|
endEventDi = elementRegistry.get('EndEvent_1').businessObject.di;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeElements([ task ]);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlowDi.sourceElement).to.equal(startEventDi);
|
|
|
|
expect(sequenceFlowDi.targetElement).to.equal(endEventDi);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should update on drop on flow', inject(function(modeling, elementRegistry, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
// sequence flow with existing sourceElement and targetElement di information
|
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
|
|
|
|
startEventDi = elementRegistry.get('StartEvent_2').businessObject.di;
|
|
|
|
|
|
|
|
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' }),
|
|
|
|
dropPosition = { x: 320, y: 260 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
var event = modeling.createShape(intermediateThrowEvent, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.di.sourceElement).to.equal(startEventDi);
|
|
|
|
expect(sequenceFlow.businessObject.di.targetElement).to.equal(event.businessObject.di);
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should not create new di refs', inject(function(modeling, elementRegistry, elementFactory) {
|
|
|
|
|
|
|
|
// given
|
2018-03-22 11:43:36 +00:00
|
|
|
// sequence flow without any sourceElement and targetElement di information
|
2016-10-28 15:42:42 +00:00
|
|
|
var sequenceFlow = elementRegistry.get('SequenceFlow_4');
|
|
|
|
|
|
|
|
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' }),
|
|
|
|
dropPosition = { x: 320, y: 260 };
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.createShape(intermediateThrowEvent, dropPosition, sequenceFlow);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.businessObject.di.sourceElement).not.to.exist;
|
|
|
|
expect(sequenceFlow.businessObject.di.targetElement).not.to.exist;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|