bpmn-js/test/spec/features/modeling/behavior/UnclaimIdBehaviorSpec.js
Philipp Fromme fe11c2ee78 fix(modeling): unclaim ID on shape/connection delete
* unclaim ID of deleted shapes and connections
* unclaim ID of referenced processes when deleting participant
* this does NOT ensure we unclaim IDs of elements like DI, events, errors, ...

Related to camunda/camunda-modeler#1503
Related to #608
2019-11-18 09:57:51 +01:00

85 lines
2.1 KiB
JavaScript

import {
bootstrapModeler,
inject
} from 'test/TestHelper';
import coreModule from 'lib/core';
import modelingModule from 'lib/features/modeling';
describe('features/modeling - unclaim id', function() {
var testModules = [ coreModule, modelingModule ];
var diagramXML = require('./UnclaimIdBehaviorSpec.bpmn');
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should unclaim ID of shape', inject(function(elementRegistry, moddle, modeling) {
// given
var startEvent = elementRegistry.get('StartEvent_1');
// when
modeling.removeElements([ startEvent ]);
// then
expect(moddle.ids.assigned('StartEvent_1')).to.be.false;
}));
it('should unclaim ID of process', inject(function(elementRegistry, moddle, modeling) {
// given
var participant = elementRegistry.get('Participant_1');
// when
modeling.removeElements([ participant ]);
// then
expect(moddle.ids.assigned('Process_1')).to.be.false;
}));
it('should unclaim ID of connection', inject(function(elementRegistry, moddle, modeling) {
// given
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
// when
modeling.removeElements([ sequenceFlow ]);
// then
expect(moddle.ids.assigned('SequenceFlow_1')).to.be.false;
}));
it('should unclaim ID of children', inject(function(elementRegistry, moddle, modeling) {
// given
var participant = elementRegistry.get('Participant_1');
// when
modeling.removeElements([ participant ]);
// then
expect(moddle.ids.assigned('StartEvent_1')).to.be.false;
expect(moddle.ids.assigned('SequenceFlow_1')).to.be.false;
expect(moddle.ids.assigned('EndEvent_1')).to.be.false;
}));
it('should unclaim ID of root', inject(function(elementRegistry, moddle, modeling) {
// given
var participant = elementRegistry.get('Participant_1');
// when
modeling.removeElements([ participant ]);
// then
expect(moddle.ids.assigned('Collaboration_1')).to.be.false;
}));
});