From d32da9001309b2bef64db3b3e20cb86cdecb5410 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 5 Jan 2018 14:32:52 +0100 Subject: [PATCH] chore(lint): bump eslint ...and fix lint errors --- .eslintrc | 5 +- lib/draw/PathMap.js | 2 +- .../context-pad/ContextPadProvider.js | 67 ++++-- .../editor-actions/BpmnEditorActions.js | 20 +- lib/features/palette/PaletteProvider.js | 7 +- .../popup-menu/ReplaceMenuProvider.js | 17 +- lib/features/popup-menu/util/TypeUtil.js | 4 +- lib/features/replace/BpmnReplace.js | 12 +- lib/features/rules/BpmnRules.js | 87 ++++--- package.json | 2 +- .../custom-elements/CustomElementFactory.js | 4 +- .../custom-elements/CustomRenderer.js | 4 +- .../custom-elements/CustomRules.js | 2 +- .../context-pad/ContextPadProviderSpec.js | 20 +- test/spec/features/modeling/DropSpec.js | 51 ++-- .../behavior/CreateParticipantBehaviorSpec.js | 20 +- .../behavior/DataStoreBehaviorSpec.js | 14 +- .../behavior/DropOnFlowBehaviorSpec.js | 227 +++++++++--------- .../ToggleElementCollapseBehaviourSpec.js | 45 ++-- .../modeling/layout/LayoutMessageFlowSpec.js | 10 +- test/spec/import/ImporterSpec.js | 18 +- 21 files changed, 348 insertions(+), 290 deletions(-) diff --git a/.eslintrc b/.eslintrc index 494ac522..3c0c00b2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/lib/draw/PathMap.js b/lib/draw/PathMap.js index 88eb2db0..ad2bb070 100644 --- a/lib/draw/PathMap.js +++ b/lib/draw/PathMap.js @@ -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) { diff --git a/lib/features/context-pad/ContextPadProvider.js b/lib/features/context-pad/ContextPadProvider.js index 95bf4c3e..cba0bf3a 100644 --- a/lib/features/context-pad/ContextPadProvider.js +++ b/lib/features/context-pad/ContextPadProvider.js @@ -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' + ) }); } } diff --git a/lib/features/editor-actions/BpmnEditorActions.js b/lib/features/editor-actions/BpmnEditorActions.js index fb2b26d0..68f5984e 100644 --- a/lib/features/editor-actions/BpmnEditorActions.js +++ b/lib/features/editor-actions/BpmnEditorActions.js @@ -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', diff --git a/lib/features/palette/PaletteProvider.js b/lib/features/palette/PaletteProvider.js index 828f088d..3a1bb257 100644 --- a/lib/features/palette/PaletteProvider.js +++ b/lib/features/palette/PaletteProvider.js @@ -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, diff --git a/lib/features/popup-menu/ReplaceMenuProvider.js b/lib/features/popup-menu/ReplaceMenuProvider.js index 7fdc2d12..601c9404 100644 --- a/lib/features/popup-menu/ReplaceMenuProvider.js +++ b/lib/features/popup-menu/ReplaceMenuProvider.js @@ -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') || diff --git a/lib/features/popup-menu/util/TypeUtil.js b/lib/features/popup-menu/util/TypeUtil.js index 9705bb7a..b6e257b5 100644 --- a/lib/features/popup-menu/util/TypeUtil.js +++ b/lib/features/popup-menu/util/TypeUtil.js @@ -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; diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index 7b01f04a..7bbfdbbe 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -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; } diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index ef1eb21e..a8d4f3ec 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -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) + ) ); } diff --git a/package.json b/package.json index 547aa11d..b16611f3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/integration/custom-elements/CustomElementFactory.js b/test/integration/custom-elements/CustomElementFactory.js index 6b97ad73..6e9e3fb5 100644 --- a/test/integration/custom-elements/CustomElementFactory.js +++ b/test/integration/custom-elements/CustomElementFactory.js @@ -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 = {}; diff --git a/test/integration/custom-elements/CustomRenderer.js b/test/integration/custom-elements/CustomRenderer.js index 14c01545..c836a28e 100644 --- a/test/integration/custom-elements/CustomRenderer.js +++ b/test/integration/custom-elements/CustomRenderer.js @@ -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, diff --git a/test/integration/custom-elements/CustomRules.js b/test/integration/custom-elements/CustomRules.js index b3012b30..68bda94d 100644 --- a/test/integration/custom-elements/CustomRules.js +++ b/test/integration/custom-elements/CustomRules.js @@ -15,7 +15,7 @@ function isType(element, type) { } function isCustom(element) { - return element && /^custom\:/.test(element.type); + return element && /^custom:/.test(element.type); } /** diff --git a/test/spec/features/context-pad/ContextPadProviderSpec.js b/test/spec/features/context-pad/ContextPadProviderSpec.js index 31ba7849..feb49722 100644 --- a/test/spec/features/context-pad/ContextPadProviderSpec.js +++ b/test/spec/features/context-pad/ContextPadProviderSpec.js @@ -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 + ', 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' }), diff --git a/test/spec/features/modeling/DropSpec.js b/test/spec/features/modeling/DropSpec.js index a6ddbb21..4bea532d 100644 --- a/test/spec/features/modeling/DropSpec.js +++ b/test/spec/features/modeling/DropSpec.js @@ -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); + } + )); }); diff --git a/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js b/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js index 652c093d..f413bc53 100644 --- a/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js @@ -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); + } + )); }); diff --git a/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js b/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js index ab997b00..d7c56cab 100644 --- a/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js @@ -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; diff --git a/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js b/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js index 736765b2..33607977 100644 --- a/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js @@ -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; })); + }); }); diff --git a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js index be78d9b6..4b50ac23 100644 --- a/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js +++ b/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js @@ -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() { }); - - }); diff --git a/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js b/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js index 9eab4cff..c30511aa 100644 --- a/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js +++ b/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js @@ -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 } ]); }) ); diff --git a/test/spec/import/ImporterSpec.js b/test/spec/import/ImporterSpec.js index ac407ded..d46e3601 100644 --- a/test/spec/import/ImporterSpec.js +++ b/test/spec/import/ImporterSpec.js @@ -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);