forked from bpmn-io/bpmn-js-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BpmnPropertiesSpec.js
110 lines (73 loc) · 2.49 KB
/
BpmnPropertiesSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import {
bootstrapModeler,
inject
} from '../TestHelper';
import coreModule from 'bpmn-js/lib/core';
import modelingModule from 'bpmn-js/lib/features/modeling';
describe('bpmn properties', function() {
var testModules = [
coreModule,
modelingModule
];
var diagramXML = require('./diagram.bpmn');
beforeEach(bootstrapModeler(diagramXML, {
modules: testModules
}));
describe('read properties', function() {
it('should read name', inject(function(elementRegistry) {
// given
var sequenceFlowElement = elementRegistry.get('SequenceFlow_1'),
sequenceFlow = sequenceFlowElement.businessObject;
// when
var name = sequenceFlow.name;
// then
expect(name).to.eql('FOO > BAR?');
}));
it('should read conditionExpression', inject(function(elementRegistry) {
// given
var sequenceFlowElement = elementRegistry.get('SequenceFlow_1'),
sequenceFlow = sequenceFlowElement.businessObject;
// when
var condition = sequenceFlow.conditionExpression;
// then
expect(condition.body).to.eql('${foo > bar}');
}));
});
describe('write properties', function() {
it('should write conditionExpression', inject(
function(elementRegistry, moddle, modeling) {
// given
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
var newCondition = moddle.create('bpmn:FormalExpression', {
body: '${ value > 100 }'
});
// assume
expect(sequenceFlow.conditionExpression).not.to.exist;
// when
modeling.updateProperties(sequenceFlowElement, {
conditionExpression: newCondition
});
// then
expect(sequenceFlow.conditionExpression).to.equal(newCondition);
}
));
it('should undo write conditionExpression', inject(
function(elementRegistry, moddle, modeling, commandStack) {
// given
var sequenceFlowElement = elementRegistry.get('SequenceFlow_2'),
sequenceFlow = sequenceFlowElement.businessObject;
var newCondition = moddle.create('bpmn:FormalExpression', {
body: '${ value > 100 }'
});
modeling.updateProperties(sequenceFlowElement, {
conditionExpression: newCondition
});
// when
commandStack.undo();
// then
expect(sequenceFlow.conditionExpression).not.to.exist;
}
));
});
});