2014-08-22 13:20:48 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var Matchers = require('../../../Matchers'),
|
|
|
|
TestHelper = require('../../../TestHelper');
|
|
|
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
2014-10-30 11:06:43 +00:00
|
|
|
coreModule = require('../../../../lib/core');
|
2014-08-22 13:20:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('features/modeling - #removeConnection', function() {
|
|
|
|
|
|
|
|
beforeEach(Matchers.addDeepEquals);
|
|
|
|
|
|
|
|
|
2014-11-20 11:56:39 +00:00
|
|
|
var diagramXML = fs.readFileSync('test/fixtures/bpmn/sequence-flows.bpmn', 'utf8');
|
2014-08-22 13:20:48 +00:00
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var testModules = [ coreModule, modelingModule ];
|
2014-08-22 13:20:48 +00:00
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
|
|
|
|
|
|
|
|
|
|
|
describe('shape handling', function() {
|
|
|
|
|
|
|
|
it('should execute', inject(function(elementRegistry, modeling) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowShape = elementRegistry.get('SequenceFlow_2'),
|
2014-08-22 13:20:48 +00:00
|
|
|
sequenceFlow = sequenceFlowShape.businessObject;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeConnection(sequenceFlowShape);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.$parent).toBeNull();
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('undo support', function() {
|
|
|
|
|
|
|
|
it('should undo', inject(function(elementRegistry, modeling, commandStack) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowShape = elementRegistry.get('SequenceFlow_2'),
|
2014-08-22 13:20:48 +00:00
|
|
|
sequenceFlow = sequenceFlowShape.businessObject,
|
|
|
|
parent = sequenceFlow.$parent;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeConnection(sequenceFlowShape);
|
|
|
|
commandStack.undo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.$parent).toBe(parent);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('redo support', function() {
|
|
|
|
|
|
|
|
it('redo', inject(function(elementRegistry, modeling, commandStack) {
|
|
|
|
|
|
|
|
// given
|
2014-11-17 16:36:22 +00:00
|
|
|
var sequenceFlowShape = elementRegistry.get('SequenceFlow_2'),
|
2014-08-22 13:20:48 +00:00
|
|
|
sequenceFlow = sequenceFlowShape.businessObject,
|
|
|
|
parent = sequenceFlow.$parent;
|
|
|
|
|
|
|
|
// when
|
|
|
|
modeling.removeConnection(sequenceFlowShape);
|
|
|
|
commandStack.undo();
|
|
|
|
commandStack.redo();
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(sequenceFlow.$parent).toBeNull();
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|