Files
bpmn-js/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js
Nico Rehwaldt d3449ca87c chore(project): es6ify source code
* use ES6 import / export
* UTILS: export individual utilities
* TESTS: localize TestHelper includes

BREAKING CHANGE:

* all utilities export independent functions
* library sources got ported to ES6. You must now use
  a ES module bundler such as Browserify + babelify or
  Webpack to consume this library (or parts of it).
2018-04-03 16:32:14 +02:00

81 lines
2.1 KiB
JavaScript

'use strict';
import {
bootstrapModeler,
inject
} from 'test/TestHelper';
import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';
describe('features/modeling - delete default connection', function() {
var testModules = [ coreModule, modelingModule ];
var processDiagramXML = require('./UnsetDefaultFlowBehaviorSpec.bpmn');
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
var gateway,
defaultConnection,
normalConnection;
beforeEach(inject(function(elementRegistry) {
gateway = elementRegistry.get('exclusive-gateway');
defaultConnection = elementRegistry.get('flow-default');
normalConnection = elementRegistry.get('flow-normal');
}));
it('should remove default connection', inject(function(modeling) {
// when
modeling.removeConnection(defaultConnection);
// then
expect(defaultConnection.parent).to.be.null;
expect(gateway.businessObject.default).to.be.null; // .property('default');
}));
it('should revert default connection', inject(function(modeling, commandStack) {
// given
modeling.removeConnection(defaultConnection);
// when
commandStack.undo();
// then
expect(defaultConnection.parent).to.be.not.null;
expect(gateway.businessObject.default).to.eql(defaultConnection.businessObject);
}));
it('should NOT remove default connection on removing other connections', inject(function(modeling) {
// when
modeling.removeConnection(normalConnection);
// then
expect(normalConnection.parent).to.be.null;
expect(defaultConnection.parent).to.be.not.null;
expect(gateway.businessObject.default).to.eql(defaultConnection.businessObject);
}));
it('should NOT remove default connection on restoring other connections', inject(function(modeling, commandStack) {
// given
modeling.removeConnection(normalConnection);
// when
commandStack.undo();
// then
expect(normalConnection.parent).to.be.not.null;
expect(defaultConnection.parent).to.be.not.null;
expect(gateway.businessObject.default).to.eql(defaultConnection.businessObject);
}));
});