Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
y: 0
}, {
desc: 'up arrow',
keys: KEYS.UP,
shiftKey: false,
x: 0,
y: -50
}, {
desc: 'down arrow',
keys: KEYS.DOWN,
shiftKey: false,
x: 0,
y: 50
}];
forEach(decisionTable, function(testCase) {
forEach(testCase.keys, function(key) {
it('should handle ' + testCase.desc, inject(function(canvas, keyboard) {
// given
var event = createKeyEvent(key, { shiftKey: testCase.shiftKey });
// when
keyboard._keyHandler(event);
// then
expect(canvas.viewbox().x).to.eql(testCase.x);
expect(canvas.viewbox().y).to.eql(testCase.y);
}));
var participant = elementRegistry.get('Participant_0x9lnke'),
task = elementRegistry.get('Task_1'),
newTask;
// when
copyPaste.copy([ task ]);
copyPaste.paste({
element: participant,
point: {
x: 500,
y: 50
}
});
newTask = filter(participant.children, function(element) {
return is(element, 'bpmn:Task');
})[0];
// then
var bo = task.businessObject;
var copiedBo = newTask.businessObject;
expect(copiedBo.asyncBefore).to.eql(bo.asyncBefore);
expect(copiedBo.documentation).to.jsonEqual(bo.documentation);
var copiedExtensions = copiedBo.extensionElements;
expect(copiedExtensions).to.jsonEqual(bo.extensionElements);
expect(copiedExtensions.$parent).to.equal(copiedBo);
})
function write(element, options, callback) {
if (isFunction(options)) {
callback = options;
options = {};
}
// skip preamble for tests
options = assign({ preamble: false }, options);
moddle.toXML(element, options, callback);
}
function createKeyEvent(key, attrs) {
var event = document.createEvent('Events') || new document.defaultView.CustomEvent('keyEvent');
// init and mark as bubbles / cancelable
event.initEvent('keydown', false, true);
var keyAttrs = isString(key) ? { key: key } : { keyCode: key, which: key };
return assign(event, keyAttrs, attrs || {});
}
endEventShape,
dropPosition,
sequenceFlow
);
// then
// new incoming connection
expect(newShape.incoming.length).to.equal(1);
expect(newShape.incoming[0]).to.eql(sequenceFlow);
// no outgoing edges
expect(newShape.outgoing.length).to.equal(0);
// split target at insertion point
expect(sequenceFlow).to.have.waypoints(flatten([
originalWaypoints.slice(0, 1),
{ x: 322, y: 120 }
]));
}
));
}
let id = attrs.id;
attrs.businessObject.get = function(key) {
if (key == 'id') {
return id;
}
};
attrs.businessObject.set = function(key, value) {
if (key == 'id') {
assign(attrs.businessObject, { id: value });
}
};
// add width and height if shape
if ((!/:activity$/.test(type) || !/:connection$/.test(type)) && !(/:group$/.test(type) && attrs.height || attrs.width)) {
assign(attrs, self._getCustomElementSize(type));
}
if (!('$instanceOf' in attrs.businessObject)) {
// ensure we can use ModelUtil#is for type checks
Object.defineProperty(attrs.businessObject, '$instanceOf', {
value: function(type) {
return this.type === type;
}
});
}
return self.baseCreate(elementType, attrs);
}
return self.createBpmnElement(elementType, attrs);
};
return function(args, options) {
if (isString(args)) {
args = args.split(',');
} else
if (!isArray(args)) {
args = [ args ];
}
return args.map(function(arg) {
// assume element passed is shape already
if (isObject(arg)) {
return arg;
}
var e = elementRegistry.get(arg);
if (!e) {
if (options.optional) {
function start(event, element, activate, context) {
if (isObject(activate)) {
context = activate;
activate = false;
}
// do not move connections or the root element
if (element.waypoints || !element.parent) {
return;
}
var referencePoint = mid(element);
dragging.init(event, referencePoint, 'shape.move', {
cursor: 'grabbing',
autoActivate: activate,
data: {
shape: element,
});
elements = map(elements, function(element) {
return {
primaryTokens: matchAndSplit(labelUtil.getLabel(element), pattern),
secondaryTokens: matchAndSplit(element.id, pattern),
element: element
};
});
// exclude non-matched elements
elements = filter(elements, function(element) {
return hasMatched(element.primaryTokens) || hasMatched(element.secondaryTokens);
});
elements = sortBy(elements, function(element) {
return labelUtil.getLabel(element.element) + element.element.id;
});
return elements;
};
forEach(tree, function(branch, depth) {
depth = parseInt(depth, 10);
// sort by priority
branch = sortBy(branch, 'priority');
forEach(branch, function(descriptor) {
// remove priority
var attrs = assign({}, omit(descriptor, [ 'priority' ]));
if (cache[ descriptor.parent ]) {
attrs.parent = cache[ descriptor.parent ];
} else {
delete attrs.parent;
}
eventBus.fire('copyPaste.pasteElement', {
cache: cache,
descriptor: attrs
});