2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
getBpmnJS
|
|
|
|
} from 'test/TestHelper';
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function expectCanConnect(source, target, rules) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
var results = {};
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
source = elementRegistry.get(source);
|
|
|
|
target = elementRegistry.get(target);
|
|
|
|
|
|
|
|
expect(source).to.exist;
|
|
|
|
expect(target).to.exist;
|
|
|
|
|
|
|
|
if ('sequenceFlow' in rules) {
|
|
|
|
results.sequenceFlow = bpmnRules.canConnectSequenceFlow(source, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('messageFlow' in rules) {
|
|
|
|
results.messageFlow = bpmnRules.canConnectMessageFlow(source, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('association' in rules) {
|
|
|
|
results.association = bpmnRules.canConnectAssociation(source, target);
|
|
|
|
}
|
2015-10-06 10:33:21 +00:00
|
|
|
|
|
|
|
if ('dataAssociation' in rules) {
|
|
|
|
results.dataAssociation = bpmnRules.canConnectDataAssociation(source, target);
|
|
|
|
}
|
2015-07-30 08:48:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).to.eql(rules);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function expectCanDrop(element, target, expectedResult) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
var result;
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
element = elementRegistry.get(element);
|
|
|
|
target = elementRegistry.get(target);
|
|
|
|
|
|
|
|
expect(element).to.exist;
|
|
|
|
expect(target).to.exist;
|
|
|
|
|
|
|
|
result = bpmnRules.canDrop(element, target);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(result).to.eql(expectedResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
export function expectCanMove(elements, target, rules) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
var results = {};
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
getBpmnJS().invoke(function(elementRegistry, bpmnRules) {
|
2015-07-30 08:48:17 +00:00
|
|
|
|
|
|
|
target = elementRegistry.get(target);
|
|
|
|
|
|
|
|
if ('attach' in rules) {
|
|
|
|
results.attach = bpmnRules.canAttach(elements, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('move' in rules) {
|
|
|
|
results.move = bpmnRules.canMove(elements, target);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(results).to.eql(rules);
|
2018-04-02 19:01:53 +00:00
|
|
|
}
|