Skip to content

Commit 579ce0e

Browse files
committed
test: verify additional variables follow standard scoping rules
1 parent 09dad09 commit 579ce0e

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,37 @@ describe('ZeebeVariableResolver', function() {
936936

937937
it('should scope / global', inject(async function(variableResolver, elementRegistry) {
938938

939+
// given
940+
const task = elementRegistry.get('Task_3');
941+
942+
// task has no output mapping, variable bubbles
943+
createProvider({
944+
variables: [ { name: 'globalVar' } ],
945+
origin: 'Task_3',
946+
variableResolver
947+
});
948+
949+
// when
950+
const variables = await variableResolver.getVariablesForElement(task);
951+
952+
// then
953+
// own + all variables from parent scope
954+
expect(variables).to.variableEqual([
955+
{ name: 'variable1', origin: [ 'Task_1' ], scope: 'Process_1' },
956+
{ name: 'variable2', origin: [ 'Task_1' ], scope: 'Process_1' },
957+
{ name: 'variable3', origin: [ 'SubProcess_1', 'Task_2' ], scope: 'SubProcess_1' },
958+
{ name: 'variable4', origin: [ 'Task_3' ], scope: 'Task_3' },
959+
{ name: 'globalVar', origin: [ 'Task_3' ], scope: 'Process_1' }
960+
]);
961+
}));
962+
963+
964+
it('should scope / local / output mapping', inject(async function(variableResolver, elementRegistry) {
965+
939966
// given
940967
const task = elementRegistry.get('Task_2');
941968

969+
// task has output mapping, variable <foo> is local
942970
createProvider({
943971
variables: [ { name: 'foo' } ],
944972
origin: 'Task_2',
@@ -954,7 +982,7 @@ describe('ZeebeVariableResolver', function() {
954982
{ name: 'variable1', origin: [ 'Task_1' ], scope: 'Process_1' },
955983
{ name: 'variable2', origin: [ 'Task_1' ], scope: 'Process_1' },
956984
{ name: 'variable3', origin: [ 'SubProcess_1', 'Task_2' ], scope: 'SubProcess_1' },
957-
{ name: 'foo', origin: [ 'Task_2' ], scope: 'Process_1' }
985+
{ name: 'foo', origin: [ 'Task_2' ], scope: 'Task_2' }
958986
]);
959987
}));
960988

@@ -964,6 +992,7 @@ describe('ZeebeVariableResolver', function() {
964992
// given
965993
const task = elementRegistry.get('Task_3');
966994

995+
// task has no output mapping, variable bubbles
967996
createProvider({
968997
variables: [ { name: 'variable3' } ],
969998
origin: 'Task_3',
@@ -984,13 +1013,19 @@ describe('ZeebeVariableResolver', function() {
9841013
}));
9851014

9861015

987-
it('should scope / local', inject(async function(variableResolver, elementRegistry) {
1016+
it('should scope / local / input mapping', inject(async function(variableResolver, elementRegistry) {
9881017

9891018
// given
9901019
const task = elementRegistry.get('Task_3');
9911020

1021+
// task has input mapping for <variable4>, variable is local
9921022
createProvider({
993-
variables: [ { name: 'variable4' } ],
1023+
variables: [ {
1024+
name: 'variable4',
1025+
entries: [
1026+
{ name: 'attr' }
1027+
]
1028+
} ],
9941029
origin: 'Task_3',
9951030
variableResolver
9961031
});
@@ -1004,7 +1039,14 @@ describe('ZeebeVariableResolver', function() {
10041039
{ name: 'variable1', origin: [ 'Task_1' ], scope: 'Process_1' },
10051040
{ name: 'variable2', origin: [ 'Task_1' ], scope: 'Process_1' },
10061041
{ name: 'variable3', origin: [ 'SubProcess_1', 'Task_2' ], scope: 'SubProcess_1' },
1007-
{ name: 'variable4', origin: [ 'Task_3' ], scope: 'Task_3' }
1042+
{
1043+
name: 'variable4',
1044+
origin: [ 'Task_3' ],
1045+
scope: 'Task_3',
1046+
entries: [
1047+
{ name: 'attr' }
1048+
]
1049+
}
10081050
]);
10091051
}));
10101052

0 commit comments

Comments
 (0)