style(tests): reformat DropOnFlowBehaviorSpec

This commit is contained in:
Nico Rehwaldt 2018-02-14 22:20:11 +01:00
parent f5afc732fe
commit de63fd49a3
1 changed files with 191 additions and 152 deletions

View File

@ -17,19 +17,27 @@ describe('modeling/behavior - drop on connection', function() {
var diagramXML = require('./DropOnFlowBehavior.bpmn'); var diagramXML = require('./DropOnFlowBehavior.bpmn');
var testModules = [ noTouchInteractionModule, moveModule, modelingModule, coreModule ]; beforeEach(bootstrapModeler(diagramXML, {
modules: [
beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); noTouchInteractionModule,
moveModule,
modelingModule,
coreModule
]
}));
describe('execution', function() { describe('execution', function() {
describe('create', function() { describe('create', function() {
it('should connect start -> target -> end', inject(function(modeling, elementRegistry, elementFactory) { it('should connect start -> target -> end', inject(
function(modeling, elementRegistry, elementFactory) {
// given // given
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' }); var intermediateThrowEvent = elementFactory.createShape({
type: 'bpmn:IntermediateThrowEvent'
});
var startEvent = elementRegistry.get('StartEvent'), var startEvent = elementRegistry.get('StartEvent'),
sequenceFlow = elementRegistry.get('SequenceFlow_1'), sequenceFlow = elementRegistry.get('SequenceFlow_1'),
@ -40,7 +48,11 @@ describe('modeling/behavior - drop on connection', function() {
var dropPosition = { x: 340, y: 120 }; // first bendpoint var dropPosition = { x: 340, y: 120 }; // first bendpoint
// when // when
var newShape = modeling.createShape(intermediateThrowEvent, dropPosition, sequenceFlow); var newShape = modeling.createShape(
intermediateThrowEvent,
dropPosition,
sequenceFlow
);
// then // then
@ -72,10 +84,12 @@ describe('modeling/behavior - drop on connection', function() {
])); ]));
expect(targetConnection).to.have.startDocking(dropPosition); expect(targetConnection).to.have.startDocking(dropPosition);
})); }
));
it('should connect start -> target', inject(function(modeling, elementRegistry, elementFactory) { it('should connect start -> target', inject(
function(modeling, elementRegistry, elementFactory) {
// given // given
var endEventShape = elementFactory.createShape({ type: 'bpmn:EndEvent' }); var endEventShape = elementFactory.createShape({ type: 'bpmn:EndEvent' });
@ -86,7 +100,11 @@ describe('modeling/behavior - drop on connection', function() {
var dropPosition = { x: 340, y: 120 }; // first bendpoint var dropPosition = { x: 340, y: 120 }; // first bendpoint
// when // when
var newShape = modeling.createShape(endEventShape, dropPosition, sequenceFlow); var newShape = modeling.createShape(
endEventShape,
dropPosition,
sequenceFlow
);
// then // then
@ -102,13 +120,17 @@ describe('modeling/behavior - drop on connection', function() {
originalWaypoints.slice(0, 1), originalWaypoints.slice(0, 1),
{ x: 322, y: 120 } { x: 322, y: 120 }
])); ]));
})); }
));
it('should connect target -> end', inject(function(modeling, elementRegistry, elementFactory) { it('should connect target -> end', inject(
function(modeling, elementRegistry, elementFactory) {
// given // given
var startEventShape = elementFactory.createShape({ type: 'bpmn:StartEvent' }); var startEventShape = elementFactory.createShape({
type: 'bpmn:StartEvent'
});
var sequenceFlow = elementRegistry.get('SequenceFlow_1'); var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var originalWaypoints = sequenceFlow.waypoints; var originalWaypoints = sequenceFlow.waypoints;
@ -116,7 +138,11 @@ describe('modeling/behavior - drop on connection', function() {
var dropPosition = { x: 340, y: 120 }; // first bendpoint var dropPosition = { x: 340, y: 120 }; // first bendpoint
// when // when
var newShape = modeling.createShape(startEventShape, dropPosition, sequenceFlow); var newShape = modeling.createShape(
startEventShape,
dropPosition,
sequenceFlow
);
// then // then
@ -132,7 +158,8 @@ describe('modeling/behavior - drop on connection', function() {
{ x: 340, y: 138 }, { x: 340, y: 138 },
originalWaypoints.slice(2) originalWaypoints.slice(2)
])); ]));
})); }
));
it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject( it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject(
@ -191,7 +218,8 @@ describe('modeling/behavior - drop on connection', function() {
dragging.setOptions({ manual: true }); dragging.setOptions({ manual: true });
})); }));
it('should connect start -> target -> end', inject(function(dragging, move, elementRegistry, selection) { it('should connect start -> target -> end', inject(
function(dragging, move, elementRegistry, selection) {
// given // given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'); var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
@ -246,7 +274,8 @@ describe('modeling/behavior - drop on connection', function() {
])); ]));
expect(targetConnection).to.have.startDocking({ x: 341, y: 210 }); expect(targetConnection).to.have.startDocking({ x: 341, y: 210 });
})); }
));
it('should connect start -> target -> end (hovering parent)', inject( it('should connect start -> target -> end (hovering parent)', inject(
@ -498,7 +527,8 @@ describe('modeling/behavior - drop on connection', function() {
)); ));
it('should not insert on inaccuratly found intersection', inject(function(dragging, move, elementRegistry, selection) { it('should not insert on inaccuratly found intersection', inject(
function(dragging, move, elementRegistry, selection) {
// given // given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'); var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
@ -523,7 +553,8 @@ describe('modeling/behavior - drop on connection', function() {
// then // then
expect(intermediateThrowEvent.incoming).to.have.lengthOf(0); expect(intermediateThrowEvent.incoming).to.have.lengthOf(0);
expect(intermediateThrowEvent.outgoing).to.have.lengthOf(0); expect(intermediateThrowEvent.outgoing).to.have.lengthOf(0);
})); }
));
}); });
@ -532,22 +563,28 @@ describe('modeling/behavior - drop on connection', function() {
describe('rules', function() { describe('rules', function() {
it('should be allowed for an IntermediateThrowEvent', inject(function(elementRegistry, bpmnRules, elementFactory) { it('should be allowed for an IntermediateThrowEvent', inject(
function(elementRegistry, bpmnRules, elementFactory) {
// when // when
var sequenceFlow = elementRegistry.get('SequenceFlow_1'); var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var intermediateThrowEvent = elementFactory.createShape({ type: 'bpmn:IntermediateThrowEvent' }); var intermediateThrowEvent = elementFactory.createShape({
type: 'bpmn:IntermediateThrowEvent'
});
// then // then
expect(bpmnRules.canCreate(intermediateThrowEvent, sequenceFlow)).to.be.true; expect(bpmnRules.canCreate(intermediateThrowEvent, sequenceFlow)).to.be.true;
})); }
));
it('should not insert participant', inject( it('should not insert participant', inject(
function(rules, elementRegistry, elementFactory) { function(rules, elementRegistry, elementFactory) {
// given // given
var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' }); var participantShape = elementFactory.createShape({
type: 'bpmn:Participant'
});
var sequenceFlow = elementRegistry.get('SequenceFlow_1'); var sequenceFlow = elementRegistry.get('SequenceFlow_1');
@ -606,7 +643,8 @@ describe('modeling/behavior - drop on connection', function() {
)); ));
it('should not insert on sequence flow label', inject(function(bpmnRules, elementRegistry) { it('should not insert on sequence flow label', inject(
function(bpmnRules, elementRegistry) {
// given // given
var eventShape = elementRegistry.get('IntermediateThrowEvent_foo'), var eventShape = elementRegistry.get('IntermediateThrowEvent_foo'),
@ -619,7 +657,8 @@ describe('modeling/behavior - drop on connection', function() {
// then // then
expect(canInsert).to.be.false; expect(canInsert).to.be.false;
})); }
));
}); });