chore(lint): bump eslint

...and fix lint errors
This commit is contained in:
Nico Rehwaldt 2018-01-05 14:32:52 +01:00
parent 49cc8dc7ea
commit d32da90013
21 changed files with 348 additions and 290 deletions

View File

@ -1,6 +1,9 @@
{
"rules": {
"indent": [ 2, 2, { "VariableDeclarator": { "const": 3, "let": 2, "var": 2 } } ],
"indent": [ 2, 2, {
"VariableDeclarator": { "var": 2, "let": 2, "const": 3 },
"FunctionDeclaration": { "body": 1, "parameters": 2 }
} ],
"keyword-spacing": [ 2 ],
"mocha/no-exclusive-tests": 2,
"no-console": 0,

View File

@ -452,7 +452,7 @@ module.exports = PathMap;
////////// helpers //////////
// copied from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
var tokenRegex = /\{([^\}]+)\}/g,
var tokenRegex = /\{([^}]+)\}/g,
objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
function replacer(all, key, obj) {

View File

@ -14,9 +14,10 @@ var assign = require('lodash/object/assign'),
/**
* A provider for BPMN 2.0 elements context pad
*/
function ContextPadProvider(config, injector, eventBus, contextPad, modeling,
elementFactory, connect, create, popupMenu,
canvas, rules, translate) {
function ContextPadProvider(
config, injector, eventBus, contextPad, modeling,
elementFactory, connect, create, popupMenu,
canvas, rules, translate) {
config = config || {};
@ -137,7 +138,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
if (typeof title !== 'string') {
options = title;
title = translate('Append {type}', { type: type.replace(/^bpmn\:/, '') });
title = translate('Append {type}', { type: type.replace(/^bpmn:/, '') });
}
function appendStart(event, element) {
@ -244,19 +245,30 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
if (is(businessObject, 'bpmn:EventBasedGateway')) {
assign(actions, {
'append.receive-task': appendAction('bpmn:ReceiveTask', 'bpmn-icon-receive-task'),
'append.message-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-message',
{ eventDefinitionType: 'bpmn:MessageEventDefinition' }),
'append.timer-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-timer',
{ eventDefinitionType: 'bpmn:TimerEventDefinition' }),
'append.condtion-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-condition',
{ eventDefinitionType: 'bpmn:ConditionalEventDefinition' }),
'append.signal-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-signal',
{ eventDefinitionType: 'bpmn:SignalEventDefinition' })
'append.receive-task': appendAction(
'bpmn:ReceiveTask',
'bpmn-icon-receive-task'
),
'append.message-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-message',
{ eventDefinitionType: 'bpmn:MessageEventDefinition' }
),
'append.timer-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-timer',
{ eventDefinitionType: 'bpmn:TimerEventDefinition' }
),
'append.condtion-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-condition',
{ eventDefinitionType: 'bpmn:ConditionalEventDefinition' }
),
'append.signal-intermediate-event': appendAction(
'bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-signal',
{ eventDefinitionType: 'bpmn:SignalEventDefinition' }
)
});
} else
@ -276,11 +288,22 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
!isEventSubProcess(businessObject)) {
assign(actions, {
'append.end-event': appendAction('bpmn:EndEvent', 'bpmn-icon-end-event-none'),
'append.gateway': appendAction('bpmn:ExclusiveGateway', 'bpmn-icon-gateway-xor'),
'append.append-task': appendAction('bpmn:Task', 'bpmn-icon-task'),
'append.intermediate-event': appendAction('bpmn:IntermediateThrowEvent',
'bpmn-icon-intermediate-event-none')
'append.end-event': appendAction(
'bpmn:EndEvent',
'bpmn-icon-end-event-none'
),
'append.gateway': appendAction(
'bpmn:ExclusiveGateway',
'bpmn-icon-gateway-xor'
),
'append.append-task': appendAction(
'bpmn:Task',
'bpmn-icon-task'
),
'append.intermediate-event': appendAction(
'bpmn:IntermediateThrowEvent',
'bpmn-icon-intermediate-event-none'
)
});
}
}

View File

@ -10,18 +10,12 @@ var is = require('../../util/ModelUtil').is;
var getBBox = require('diagram-js/lib/util/Elements').getBBox;
function BpmnEditorActions(
injector,
canvas, elementRegistry, selection,
spaceTool,
lassoTool,
handTool,
globalConnect,
distributeElements,
alignElements,
directEditing,
searchPad,
modeling) {
injector, canvas, elementRegistry,
selection, spaceTool, lassoTool, handTool,
globalConnect, distributeElements, alignElements,
directEditing, searchPad, modeling) {
injector.invoke(EditorActions, this);
@ -115,7 +109,9 @@ inherits(BpmnEditorActions, EditorActions);
BpmnEditorActions.$inject = [
'injector',
'canvas', 'elementRegistry', 'selection',
'canvas',
'elementRegistry',
'selection',
'spaceTool',
'lassoTool',
'handTool',

View File

@ -5,7 +5,10 @@ var assign = require('lodash/object/assign');
/**
* A palette provider for BPMN 2.0 elements.
*/
function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool, handTool, globalConnect, translate) {
function PaletteProvider(
palette, create, elementFactory,
spaceTool, lassoTool, handTool,
globalConnect, translate) {
this._palette = palette;
this._create = create;
@ -56,7 +59,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
create.start(event, shape);
}
var shortType = type.replace(/^bpmn\:/, '');
var shortType = type.replace(/^bpmn:/, '');
return {
group: group,

View File

@ -16,7 +16,9 @@ var replaceOptions = require ('../replace/ReplaceOptions');
/**
* This module is an element agnostic replace menu provider for the popup menu.
*/
function ReplaceMenuProvider(popupMenu, modeling, moddle, bpmnReplace, rules, translate) {
function ReplaceMenuProvider(
popupMenu, modeling, moddle,
bpmnReplace, rules, translate) {
this._popupMenu = popupMenu;
this._modeling = modeling;
@ -28,7 +30,14 @@ function ReplaceMenuProvider(popupMenu, modeling, moddle, bpmnReplace, rules, tr
this.register();
}
ReplaceMenuProvider.$inject = [ 'popupMenu', 'modeling', 'moddle', 'bpmnReplace', 'rules', 'translate' ];
ReplaceMenuProvider.$inject = [
'popupMenu',
'modeling',
'moddle',
'bpmnReplace',
'rules',
'translate'
];
/**
@ -311,13 +320,13 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, rep
}
break;
default:
// default flows
// default flows
if (is(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
return menuEntries.push(self._createMenuEntry(entry, element, function() {
modeling.updateProperties(element, { conditionExpression: undefined });
}));
}
// conditional flows
// conditional flows
if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:ComplexGateway') ||

View File

@ -31,8 +31,8 @@ function isDifferentType(element) {
);
var isExpandedEqual = (
target.isExpanded === undefined ||
target.isExpanded === isExpanded(businessObject)
target.isExpanded === undefined ||
target.isExpanded === isExpanded(businessObject)
);
return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;

View File

@ -27,15 +27,17 @@ var CUSTOM_PROPERTIES = [
function toggeling(element, target) {
var oldCollapsed = has(element, 'collapsed') ?
element.collapsed : !isExpanded(element);
var oldCollapsed = (
has(element, 'collapsed') ? element.collapsed : !isExpanded(element)
);
var targetCollapsed;
if (has(target, 'collapsed') || has(target, 'isExpanded')) {
// property is explicitly set so use it
targetCollapsed = has(target, 'collapsed') ?
target.collapsed : !target.isExpanded;
targetCollapsed = (
has(target, 'collapsed') ? target.collapsed : !target.isExpanded
);
} else {
// keep old state
targetCollapsed = oldCollapsed;
@ -160,7 +162,7 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling, eventBus) {
hints.moveChildren = false;
}
// apply same size
// apply same size
newElement.width = element.width;
newElement.height = element.height;
}

View File

@ -240,22 +240,26 @@ function isSameOrganization(a, b) {
}
function isMessageFlowSource(element) {
return is(element, 'bpmn:InteractionNode') &&
!isForCompensation(element) && (
!is(element, 'bpmn:Event') || (
is(element, 'bpmn:ThrowEvent') &&
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
)
return (
is(element, 'bpmn:InteractionNode') &&
!isForCompensation(element) && (
!is(element, 'bpmn:Event') || (
is(element, 'bpmn:ThrowEvent') &&
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
)
)
);
}
function isMessageFlowTarget(element) {
return is(element, 'bpmn:InteractionNode') &&
!isForCompensation(element) && (
!is(element, 'bpmn:Event') || (
is(element, 'bpmn:CatchEvent') &&
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
)
return (
is(element, 'bpmn:InteractionNode') &&
!isForCompensation(element) && (
!is(element, 'bpmn:Event') || (
is(element, 'bpmn:CatchEvent') &&
hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
)
)
);
}
@ -301,36 +305,41 @@ function hasEventDefinitionOrNone(element, eventDefinition) {
}
function isSequenceFlowSource(element) {
return is(element, 'bpmn:FlowNode') &&
!is(element, 'bpmn:EndEvent') &&
!isEventSubProcess(element) &&
!(is(element, 'bpmn:IntermediateThrowEvent') &&
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
) &&
!isCompensationBoundary(element) &&
!isForCompensation(element);
return (
is(element, 'bpmn:FlowNode') &&
!is(element, 'bpmn:EndEvent') &&
!isEventSubProcess(element) &&
!(is(element, 'bpmn:IntermediateThrowEvent') &&
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
) &&
!isCompensationBoundary(element) &&
!isForCompensation(element)
);
}
function isSequenceFlowTarget(element) {
return is(element, 'bpmn:FlowNode') &&
!is(element, 'bpmn:StartEvent') &&
!is(element, 'bpmn:BoundaryEvent') &&
!isEventSubProcess(element) &&
!(is(element, 'bpmn:IntermediateCatchEvent') &&
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
) &&
!isForCompensation(element);
return (
is(element, 'bpmn:FlowNode') &&
!is(element, 'bpmn:StartEvent') &&
!is(element, 'bpmn:BoundaryEvent') &&
!isEventSubProcess(element) &&
!(is(element, 'bpmn:IntermediateCatchEvent') &&
hasEventDefinition(element, 'bpmn:LinkEventDefinition')
) &&
!isForCompensation(element)
);
}
function isEventBasedTarget(element) {
return is(element, 'bpmn:ReceiveTask') || (
is(element, 'bpmn:IntermediateCatchEvent') && (
hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
hasEventDefinition(element, 'bpmn:SignalEventDefinition')
)
return (
is(element, 'bpmn:ReceiveTask') || (
is(element, 'bpmn:IntermediateCatchEvent') && (
hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
hasEventDefinition(element, 'bpmn:SignalEventDefinition')
)
)
);
}
@ -710,8 +719,10 @@ function canCreate(shape, target, source, position) {
function canResize(shape, newBounds) {
if (is(shape, 'bpmn:SubProcess')) {
return (!!isExpanded(shape)) && (
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
return (
isExpanded(shape) && (
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
)
);
}

View File

@ -41,7 +41,7 @@
"chai": "^4.1.2",
"chai-match": "^1.1.1",
"common-shakeify": "^0.4.4",
"eslint": "^3.19.0",
"eslint": "^4.14.0",
"eslint-plugin-mocha": "^4.9.0",
"grunt": "^0.4.4",
"grunt-cli": "^0.1.13",

View File

@ -21,8 +21,8 @@ function CustomElementFactory(injector) {
return self.baseCreate(elementType, assign({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));
}
if (/^custom\:/.test(type)) {
type = attrs.type.replace(/^custom\:/, '');
if (/^custom:/.test(type)) {
type = attrs.type.replace(/^custom:/, '');
businessObject = {};

View File

@ -120,7 +120,7 @@ CustomRenderer.$inject = [ 'eventBus', 'styles' ];
CustomRenderer.prototype.canRender = function(element) {
return /^custom\:/.test(element.type);
return /^custom:/.test(element.type);
};
CustomRenderer.prototype.drawShape = function(visuals, element) {
@ -140,7 +140,7 @@ CustomRenderer.prototype.drawConnection = function(visuals, element) {
};
CustomRenderer.prototype.getShapePath = function(element) {
var type = element.type.replace(/^custom\:/, '');
var type = element.type.replace(/^custom:/, '');
var shapes = {
triangle: this.getTrianglePath,

View File

@ -15,7 +15,7 @@ function isType(element, type) {
}
function isCustom(element) {
return element && /^custom\:/.test(element.type);
return element && /^custom:/.test(element.type);
}
/**

View File

@ -371,8 +371,8 @@ describe('features - context-pad', function() {
}));
it('should hide wrench if replacement is disallowed',
inject(function(elementRegistry, contextPad, customRules) {
it('should hide wrench if replacement is disallowed', inject(
function(elementRegistry, contextPad, customRules) {
// given
var element = elementRegistry.get('StartEvent_1');
@ -393,8 +393,8 @@ describe('features - context-pad', function() {
));
it('should show wrench if replacement is allowed',
inject(function(elementRegistry, contextPad, customRules) {
it('should show wrench if replacement is allowed', inject(
function(elementRegistry, contextPad, customRules) {
// given
var element = elementRegistry.get('EndEvent_1');
@ -417,8 +417,8 @@ describe('features - context-pad', function() {
describe('create + <CTRL>', function() {
it('should open replace',
inject(function(create, dragging, canvas, elementFactory) {
it('should open replace', inject(
function(create, dragging, canvas, elementFactory) {
// given
var rootShape = canvas.getRootElement(),
@ -442,8 +442,8 @@ describe('features - context-pad', function() {
));
it('should open boundary event replace menu',
inject(function(create, dragging, canvas, elementFactory, modeling, popupMenu) {
it('should open boundary event replace menu', inject(
function(create, dragging, canvas, elementFactory, modeling, popupMenu) {
// given
var rootShape = canvas.getRootElement();
@ -469,8 +469,8 @@ describe('features - context-pad', function() {
));
it('should not open non-existing replace menu',
inject(function(create, dragging, canvas, elementFactory) {
it('should not open non-existing replace menu', inject(
function(create, dragging, canvas, elementFactory) {
// given
var rootShape = canvas.getRootElement(),
dataObject = elementFactory.createShape({ type: 'bpmn:DataObjectReference' }),

View File

@ -60,38 +60,41 @@ describe('features/move - drop', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should remove flow if target and source have different parents',
inject(function(elementRegistry, modeling) {
it('should remove flow if target and source have different parents', inject(
function(elementRegistry, modeling) {
// given
var task_1 = elementRegistry.get('ID_Task_1'),
parent = elementRegistry.get('ID_SubProcess_1'),
flow = elementRegistry.get('ID_Sequenceflow_1');
// given
var task_1 = elementRegistry.get('ID_Task_1'),
parent = elementRegistry.get('ID_SubProcess_1'),
flow = elementRegistry.get('ID_Sequenceflow_1');
// when
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
// when
modeling.moveElements([ task_1 ], { x: 0, y: 200 }, parent);
// then
expect(flow.parent).to.be.null;
expect(flow.businessObject.$parent).to.be.null;
}));
// then
expect(flow.parent).to.be.null;
expect(flow.businessObject.$parent).to.be.null;
}
));
it('should update flow parent if target and source have same parents', inject(function(elementRegistry, modeling) {
it('should update flow parent if target and source have same parents', inject(
function(elementRegistry, modeling) {
// given
var task_1 = elementRegistry.get('ID_Task_1'),
task_2 = elementRegistry.get('ID_Task_2'),
parent = elementRegistry.get('ID_SubProcess_1'),
flow = elementRegistry.get('ID_Sequenceflow_1');
// given
var task_1 = elementRegistry.get('ID_Task_1'),
task_2 = elementRegistry.get('ID_Task_2'),
parent = elementRegistry.get('ID_SubProcess_1'),
flow = elementRegistry.get('ID_Sequenceflow_1');
// when
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 250 }, parent);
// when
modeling.moveElements([ task_1, task_2 ], { x: 0, y: 250 }, parent);
// then
expect(flow.parent).to.eql(parent);
expect(flow.businessObject.$parent).to.eql(parent.businessObject);
}));
// then
expect(flow.parent).to.eql(parent);
expect(flow.businessObject.$parent).to.eql(parent.businessObject);
}
));
});

View File

@ -153,20 +153,22 @@ describe('features/modeling - create participant', function() {
}));
it('should detach DI on update canvas root', inject(function(canvas, elementFactory, commandStack, modeling, elementRegistry) {
it('should detach DI on update canvas root', inject(
function(canvas, elementFactory, commandStack, modeling, elementRegistry) {
// when
modeling.makeCollaboration();
modeling.makeCollaboration();
var startEventElement = elementRegistry.get('StartEvent_1'),
startEventDi = startEventElement.businessObject.di,
rootElement = canvas.getRootElement(),
rootShapeDi = rootElement.businessObject.di;
var startEventElement = elementRegistry.get('StartEvent_1'),
startEventDi = startEventElement.businessObject.di,
rootElement = canvas.getRootElement(),
rootShapeDi = rootElement.businessObject.di;
// then
expect(startEventDi.$parent).to.not.be.ok;
expect(rootShapeDi.planeElement).not.to.include(startEventDi);
}));
expect(startEventDi.$parent).to.not.be.ok;
expect(rootShapeDi.planeElement).not.to.include(startEventDi);
}
));
});

View File

@ -29,9 +29,10 @@ describe('features/modeling/behavior - data store', function() {
// when
var dataStoreShape = modeling.createShape(
{ type: 'bpmn:DataStoreReference' },
{ x: 220, y: 220 },
participantElement);
{ type: 'bpmn:DataStoreReference' },
{ x: 220, y: 220 },
participantElement
);
var dataStoreReference = dataStoreShape.businessObject;
@ -53,9 +54,10 @@ describe('features/modeling/behavior - data store', function() {
// when
var dataStoreShape = modeling.createShape(
{ type: 'bpmn:DataStoreReference' },
{ x: 420, y: 220 },
subProcessElement);
{ type: 'bpmn:DataStoreReference' },
{ x: 420, y: 220 },
subProcessElement
);
var dataStoreReference = dataStoreShape.businessObject;

View File

@ -150,8 +150,8 @@ describe('modeling/behavior - drop on connection', function() {
}));
it('should connect start -> target -> end (with bendpointBefore inside bbox)',
inject(function(modeling, elementRegistry, elementFactory) {
it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject(
function(modeling, elementRegistry, elementFactory) {
// given
var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
@ -173,10 +173,10 @@ describe('modeling/behavior - drop on connection', function() {
));
it('should connect start -> target -> end (with bendpointAfter inside bbox)',
inject(function(modeling, elementRegistry, elementFactory) {
it('should connect start -> target -> end (with bendpointAfter inside bbox)', inject(
function(modeling, elementRegistry, elementFactory) {
// given
// given
var taskShape = elementFactory.createShape({ type: 'bpmn:Task' }),
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
originalWaypoints = sequenceFlow.waypoints,
@ -199,6 +199,7 @@ describe('modeling/behavior - drop on connection', function() {
});
describe('move', function() {
beforeEach(inject(function(dragging) {
@ -263,8 +264,8 @@ describe('modeling/behavior - drop on connection', function() {
}));
it('should connect start -> target -> end (hovering parent)',
inject(function(dragging, move, elementRegistry, selection, canvas) {
it('should connect start -> target -> end (hovering parent)', inject(
function(dragging, move, elementRegistry, selection, canvas) {
// given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo');
@ -323,8 +324,8 @@ describe('modeling/behavior - drop on connection', function() {
));
it('should connect start -> target -> end (with bendpointBefore inside bbox)',
inject(function(elementRegistry, selection, move, dragging) {
it('should connect start -> target -> end (with bendpointBefore inside bbox)', inject(
function(elementRegistry, selection, move, dragging) {
// given
var task3 = elementRegistry.get('Task_3'),
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
@ -356,8 +357,8 @@ describe('modeling/behavior - drop on connection', function() {
));
it('should connect start -> target -> end (with bendpointAfter inside bbox)',
inject(function(elementRegistry, selection, move, dragging) {
it('should connect start -> target -> end (with bendpointAfter inside bbox)', inject(
function(elementRegistry, selection, move, dragging) {
// given
var task3 = elementRegistry.get('Task_3'),
sequenceFlow = elementRegistry.get('SequenceFlow_1'),
@ -389,87 +390,91 @@ describe('modeling/behavior - drop on connection', function() {
));
it('should connect start -> target', inject(function(modeling, elementRegistry, selection, move, dragging) {
it('should connect start -> target', inject(
function(modeling, elementRegistry, selection, move, dragging) {
// given
var endEventShape = elementRegistry.get('EndEvent_foo');
// given
var endEventShape = elementRegistry.get('EndEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
// when
selection.select(endEventShape);
// when
selection.select(endEventShape);
move.start(canvasEvent({ x: 0, y: 0 }), endEventShape);
move.start(canvasEvent({ x: 0, y: 0 }), endEventShape);
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.move(canvasEvent({ x: 150, y: 0 }));
dragging.move(canvasEvent({ x: 150, y: 0 }));
dragging.end();
dragging.end();
// then
// then
// new incoming connection
expect(endEventShape.incoming.length).to.equal(1);
expect(endEventShape.incoming[0]).to.eql(sequenceFlow);
// new incoming connection
expect(endEventShape.incoming.length).to.equal(1);
expect(endEventShape.incoming[0]).to.eql(sequenceFlow);
// no outgoing edges
expect(endEventShape.outgoing.length).to.equal(0);
// no outgoing edges
expect(endEventShape.outgoing.length).to.equal(0);
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([
originalWaypoints.slice(0, 2),
{ x: 340, y: 281 }
]));
}));
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([
originalWaypoints.slice(0, 2),
{ x: 340, y: 281 }
]));
}
));
it('should connect target -> end', inject(function(modeling, elementRegistry, dragging, selection, move) {
it('should connect target -> end', inject(
function(modeling, elementRegistry, dragging, selection, move) {
var startEventShape = elementRegistry.get('StartEvent_foo');
var startEventShape = elementRegistry.get('StartEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow),
originalWaypoints = sequenceFlow.waypoints;
// when
selection.select(startEventShape);
// when
selection.select(startEventShape);
move.start(canvasEvent({ x: 0, y: 0 }), startEventShape);
move.start(canvasEvent({ x: 0, y: 0 }), startEventShape);
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.move(canvasEvent({ x: -215, y: 0 }));
dragging.move(canvasEvent({ x: -215, y: 0 }));
dragging.end();
dragging.end();
// then
// then
// no incoming connection
expect(startEventShape.incoming.length).to.equal(0);
// no incoming connection
expect(startEventShape.incoming.length).to.equal(0);
// 1 outgoing connection
expect(startEventShape.outgoing.length).to.equal(1);
expect(startEventShape.outgoing[0]).to.eql(sequenceFlow);
// 1 outgoing connection
expect(startEventShape.outgoing.length).to.equal(1);
expect(startEventShape.outgoing[0]).to.eql(sequenceFlow);
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([
{ x: 338, y: 228 },
originalWaypoints.slice(2)
]));
}));
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([
{ x: 338, y: 228 },
originalWaypoints.slice(2)
]));
}
));
it('should undo',
inject(function(modeling, elementRegistry, dragging, selection, move, commandStack) {
it('should undo', inject(
function(modeling, elementRegistry, dragging, selection, move, commandStack) {
// given
var startEventShape = elementRegistry.get('StartEvent_foo');
@ -504,7 +509,8 @@ describe('modeling/behavior - drop on connection', function() {
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([ originalWaypoints ]));
}));
}
));
});
@ -513,63 +519,67 @@ describe('modeling/behavior - drop on connection', function() {
describe('rules', function() {
it('should not insert participant', inject(function(rules, elementRegistry, elementFactory) {
it('should not insert participant', inject(
function(rules, elementRegistry, elementFactory) {
// given
var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' });
// given
var participantShape = elementFactory.createShape({ type: 'bpmn:Participant' });
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var sequenceFlow = elementRegistry.get('SequenceFlow_1');
var dropPosition = { x: 340, y: 120 }; // first bendpoint
var dropPosition = { x: 340, y: 120 }; // first bendpoint
// when
var canDrop = rules.allowed('shape.create', {
shape: participantShape,
parent: sequenceFlow,
dropPosition: dropPosition
});
// when
var canDrop = rules.allowed('shape.create', {
shape: participantShape,
parent: sequenceFlow,
dropPosition: dropPosition
});
// then
expect(canDrop).to.be.false;
}));
// then
expect(canDrop).to.be.false;
}
));
it('should not insert multiple with "move"', inject(function(elementRegistry, selection, move, dragging) {
it('should not insert multiple with "move"', inject(
function(elementRegistry, selection, move, dragging) {
// given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'),
endEventShape = elementRegistry.get('EndEvent_foo');
// given
var intermediateThrowEvent = elementRegistry.get('IntermediateThrowEvent_foo'),
endEventShape = elementRegistry.get('EndEvent_foo');
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow);
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
sequenceFlowGfx = elementRegistry.getGraphics(sequenceFlow);
var intInitPosition = {
x: intermediateThrowEvent.x,
y: intermediateThrowEvent.y
},
endInitPosition = {
x: endEventShape.x,
y: endEventShape.y
};
var intInitPosition = {
x: intermediateThrowEvent.x,
y: intermediateThrowEvent.y
},
endInitPosition = {
x: endEventShape.x,
y: endEventShape.y
};
selection.select([ intermediateThrowEvent, endEventShape ]);
selection.select([ intermediateThrowEvent, endEventShape ]);
// when
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
// when
move.start(canvasEvent({ x: 0, y: 0 }), intermediateThrowEvent);
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.hover({
element: sequenceFlow,
gfx: sequenceFlowGfx
});
dragging.move(canvasEvent({ x: -215, y: 0 }));
dragging.move(canvasEvent({ x: -215, y: 0 }));
dragging.end();
dragging.end();
// then
expect(intermediateThrowEvent).to.have.position(intInitPosition);
expect(endEventShape).to.have.position(endInitPosition);
}));
// then
expect(intermediateThrowEvent).to.have.position(intInitPosition);
expect(endEventShape).to.have.position(endInitPosition);
}
));
it('should not insert on sequence flow label', inject(function(bpmnRules, elementRegistry) {
@ -586,6 +596,7 @@ describe('modeling/behavior - drop on connection', function() {
// then
expect(canInsert).to.be.false;
}));
});
});

View File

@ -339,28 +339,28 @@ describe('features/modeling - collapse and expand elements', function() {
it('hide all children',
inject(function(elementRegistry, bpmnReplace) {
inject(function(elementRegistry, bpmnReplace) {
// given
var expandedSubProcess = elementRegistry.get('SubProcess_2');
var originalChildren = expandedSubProcess.children.slice();
// given
var expandedSubProcess = elementRegistry.get('SubProcess_2');
var originalChildren = expandedSubProcess.children.slice();
// when
var collapsedSubProcess = bpmnReplace.replaceElement(expandedSubProcess,
{
type: 'bpmn:SubProcess',
isExpanded: false
}
);
// when
var collapsedSubProcess = bpmnReplace.replaceElement(expandedSubProcess,
{
type: 'bpmn:SubProcess',
isExpanded: false
}
);
// then keep children
originalChildren.forEach(function(c) {
expect(collapsedSubProcess.children).to.include(c);
});
// then keep children
originalChildren.forEach(function(c) {
expect(collapsedSubProcess.children).to.include(c);
});
// and hide them
expect(collapsedSubProcess.children).to.satisfy(allHidden());
})
// and hide them
expect(collapsedSubProcess.children).to.satisfy(allHidden());
})
);
@ -388,7 +388,6 @@ describe('features/modeling - collapse and expand elements', function() {
describe('resize', function() {
it('is centered and has default bounds',
inject(function(elementRegistry, bpmnReplace) {
@ -418,14 +417,13 @@ describe('features/modeling - collapse and expand elements', function() {
expect(collapsedSubProcess.height).to.be.at.least(defaultSize.height);
})
);
);
});
describe('undo', function() {
it('collapsed marker is removed',
inject(function(elementRegistry, bpmnReplace, commandStack) {
@ -509,10 +507,8 @@ describe('features/modeling - collapse and expand elements', function() {
describe('attaching marker', function() {
describe('collapsed', function() {
it('add ad-hoc-marker does not call toggleProvider',
inject(function(eventBus, bpmnReplace, elementRegistry) {
@ -567,7 +563,6 @@ describe('features/modeling - collapse and expand elements', function() {
describe('expanded', function() {
it('add ad-hoc-marker does not call toggleProvider',
inject(function(eventBus, bpmnReplace, elementRegistry) {
@ -619,8 +614,6 @@ describe('features/modeling - collapse and expand elements', function() {
});
});

View File

@ -112,7 +112,7 @@ describe('features/modeling - layout message flows', function() {
// then
expect(messageFlowConnection).to.have.waypoints([
{ x: 902, y: 266 }, { x: 902, y: 458 }
{ x: 902, y: 266 }, { x: 902, y: 458 }
]);
})
);
@ -298,10 +298,10 @@ describe('features/modeling - layout message flows', function() {
// then
// expect cropped, repaired manhattan connection
expect(messageFlowConnection).to.have.waypoints([
{ x: 681, y: 415 },
{ x: 681, y: 315 },
{ x: 773, y: 315 },
{ x: 773, y: 214 }
{ x: 681, y: 415 },
{ x: 681, y: 315 },
{ x: 773, y: 315 },
{ x: 773, y: 214 }
]);
})
);

View File

@ -127,15 +127,15 @@ describe('import - Importer', function() {
// then
expect(events).to.eql([
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1' },
{ type: 'add', semantic: 'SubProcess_1', di: '_BPMNShape_SubProcess_2', diagramElement: 'SubProcess_1' },
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_2', diagramElement: 'StartEvent_1' },
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1' },
{ type: 'add', semantic: 'EndEvent_1', di: '_BPMNShape_EndEvent_2', diagramElement: 'EndEvent_1' },
{ type: 'add', semantic: 'StartEvent_2', di: '_BPMNShape_StartEvent_11', diagramElement: 'StartEvent_2' },
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1' },
{ type: 'add', semantic: 'SequenceFlow_2', di: 'BPMNEdge_SequenceFlow_2', diagramElement: 'SequenceFlow_2' },
{ type: 'add', semantic: 'SequenceFlow_3', di: 'BPMNEdge_SequenceFlow_3', diagramElement: 'SequenceFlow_3' }
{ type: 'add', semantic: 'Process_1', di: 'BPMNPlane_1', diagramElement: 'Process_1' },
{ type: 'add', semantic: 'SubProcess_1', di: '_BPMNShape_SubProcess_2', diagramElement: 'SubProcess_1' },
{ type: 'add', semantic: 'StartEvent_1', di: '_BPMNShape_StartEvent_2', diagramElement: 'StartEvent_1' },
{ type: 'add', semantic: 'Task_1', di: '_BPMNShape_Task_2', diagramElement: 'Task_1' },
{ type: 'add', semantic: 'EndEvent_1', di: '_BPMNShape_EndEvent_2', diagramElement: 'EndEvent_1' },
{ type: 'add', semantic: 'StartEvent_2', di: '_BPMNShape_StartEvent_11', diagramElement: 'StartEvent_2' },
{ type: 'add', semantic: 'SequenceFlow_1', di: 'BPMNEdge_SequenceFlow_1', diagramElement: 'SequenceFlow_1' },
{ type: 'add', semantic: 'SequenceFlow_2', di: 'BPMNEdge_SequenceFlow_2', diagramElement: 'SequenceFlow_2' },
{ type: 'add', semantic: 'SequenceFlow_3', di: 'BPMNEdge_SequenceFlow_3', diagramElement: 'SequenceFlow_3' }
]);
done(err);