mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-17 03:16:32 +00:00
fix(tests): fix custom elements tests
* in the context of bpmn-js returning true when asked wether two elements can be connected is not sufficient * remove BpmnConnectionPreview since it's not needed after tests are fixed Closes #1034
This commit is contained in:
parent
86b3069eaf
commit
bc4b6cbfd8
@ -17,7 +17,7 @@ import AutoResizeModule from './features/auto-resize';
|
||||
import AutoScrollModule from 'diagram-js/lib/features/auto-scroll';
|
||||
import BendpointsModule from 'diagram-js/lib/features/bendpoints';
|
||||
import ConnectModule from 'diagram-js/lib/features/connect';
|
||||
import ConnectionPreviewModule from './features/connection-preview';
|
||||
import ConnectionPreviewModule from 'diagram-js/lib/features/connection-preview';
|
||||
import ContextPadModule from './features/context-pad';
|
||||
import CopyPasteModule from './features/copy-paste';
|
||||
import CreateModule from 'diagram-js/lib/features/create';
|
||||
|
@ -1,48 +0,0 @@
|
||||
import inherits from 'inherits';
|
||||
|
||||
import ConnectionPreview from 'diagram-js/lib/features/connection-preview/ConnectionPreview';
|
||||
|
||||
/**
|
||||
* Shows connection preview.
|
||||
*
|
||||
* @param {didi.Injector} injector
|
||||
* @param {ElementFactory} elementFactory
|
||||
* @param {BpmnRules} bpmnRules
|
||||
*/
|
||||
export default function BpmnConnectionPreview(injector, elementFactory, bpmnRules) {
|
||||
injector.invoke(ConnectionPreview, this);
|
||||
|
||||
this._elementFactory = elementFactory;
|
||||
this._bpmnRules = bpmnRules;
|
||||
}
|
||||
|
||||
inherits(BpmnConnectionPreview, ConnectionPreview);
|
||||
|
||||
BpmnConnectionPreview.$inject = [
|
||||
'injector',
|
||||
'elementFactory',
|
||||
'bpmnRules'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get connection that connect source and target once connect is finished.
|
||||
*
|
||||
* @param {Object|boolean} canConnect
|
||||
* @param {djs.model.shape} source
|
||||
* @param {djs.model.shape} target
|
||||
*
|
||||
* @returns {djs.model.connection}
|
||||
*/
|
||||
BpmnConnectionPreview.prototype.getConnection = function(canConnect, source, target) {
|
||||
var attrs = canConnect;
|
||||
|
||||
if (!attrs || !attrs.type) {
|
||||
attrs = this._bpmnRules.canConnect(source, target);
|
||||
}
|
||||
|
||||
if (!attrs) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this._elementFactory.createConnection(attrs);
|
||||
};
|
@ -1,8 +0,0 @@
|
||||
import BpmnConnectionPreview from './BpmnConnectionPreview';
|
||||
import ConnectionPreviewModule from 'diagram-js/lib/features/connection-preview';
|
||||
|
||||
export default {
|
||||
__depends__: [ ConnectionPreviewModule ],
|
||||
__init__: [ 'connectionPreview' ],
|
||||
connectionPreview: [ 'type', BpmnConnectionPreview ]
|
||||
};
|
@ -78,20 +78,7 @@ CustomRules.prototype.init = function() {
|
||||
};
|
||||
|
||||
function canConnect(source, target) {
|
||||
if (isType(target, 'custom:triangle')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isType(target, 'custom:circle')) {
|
||||
if (isType(source, 'custom:triangle')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isCustom(source)) {
|
||||
return true;
|
||||
}
|
||||
return !isCustom(source) && !isCustom(target);
|
||||
}
|
||||
|
||||
function canCreate(shape, target) {
|
||||
|
@ -5,9 +5,9 @@ import {
|
||||
|
||||
import modelingModule from 'lib/features/modeling';
|
||||
import coreModule from 'lib/core';
|
||||
import connectionPreviewModule from 'lib/features/connection-preview';
|
||||
|
||||
import bendpointsModule from 'diagram-js/lib/features/bendpoints';
|
||||
import connectionPreviewModule from 'diagram-js/lib/features/connection-preview';
|
||||
import connectModule from 'diagram-js/lib/features/connect';
|
||||
import createModule from 'diagram-js/lib/features/create';
|
||||
|
||||
@ -22,12 +22,12 @@ describe('features/modeling - layout connection', function() {
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, {
|
||||
modules: [
|
||||
coreModule,
|
||||
modelingModule,
|
||||
connectModule,
|
||||
createModule,
|
||||
bendpointsModule,
|
||||
connectionPreviewModule
|
||||
connectionPreviewModule,
|
||||
connectModule,
|
||||
coreModule,
|
||||
createModule,
|
||||
modelingModule
|
||||
]
|
||||
}));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user