@fincity/kirun-js 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionDefinition,
|
|
3
|
+
FunctionExecutionParameters,
|
|
4
|
+
KIRunFunctionRepository,
|
|
5
|
+
KIRunSchemaRepository,
|
|
6
|
+
KIRuntime,
|
|
7
|
+
} from '../../../src';
|
|
8
|
+
|
|
9
|
+
test('Loop branch bug', async () => {
|
|
10
|
+
const func = {
|
|
11
|
+
name: 'testloophistory',
|
|
12
|
+
steps: {
|
|
13
|
+
create: {
|
|
14
|
+
statementName: 'create',
|
|
15
|
+
name: 'Create',
|
|
16
|
+
namespace: 'System.Context',
|
|
17
|
+
position: { left: 129.6015625, top: 23.8984375 },
|
|
18
|
+
parameterMap: {
|
|
19
|
+
name: {
|
|
20
|
+
'1nngcowEVDtBrXBhyFsfqB': {
|
|
21
|
+
key: '1nngcowEVDtBrXBhyFsfqB',
|
|
22
|
+
type: 'VALUE',
|
|
23
|
+
expression: '',
|
|
24
|
+
order: 1,
|
|
25
|
+
value: 'arr',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
schema: {
|
|
29
|
+
paM69eD4wlyJv3NLnlpRf: {
|
|
30
|
+
key: 'paM69eD4wlyJv3NLnlpRf',
|
|
31
|
+
type: 'VALUE',
|
|
32
|
+
expression: '',
|
|
33
|
+
order: 1,
|
|
34
|
+
value: { type: 'ARRAY', items: { type: 'STRING' } },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
loop: {
|
|
40
|
+
statementName: 'loop',
|
|
41
|
+
name: 'ForEachLoop',
|
|
42
|
+
namespace: 'System.Loop',
|
|
43
|
+
position: { left: 622.4461805555555, top: 855.7760416666667 },
|
|
44
|
+
parameterMap: {
|
|
45
|
+
source: {
|
|
46
|
+
'4fQaZPve4hAoLyIFbaSnEE': {
|
|
47
|
+
key: '4fQaZPve4hAoLyIFbaSnEE',
|
|
48
|
+
type: 'EXPRESSION',
|
|
49
|
+
expression: 'Context.arr',
|
|
50
|
+
order: 1,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
dependentStatements: { 'Steps.set.output': true, 'Steps.set1.output': true },
|
|
55
|
+
},
|
|
56
|
+
create1: {
|
|
57
|
+
statementName: 'create1',
|
|
58
|
+
name: 'Create',
|
|
59
|
+
namespace: 'System.Context',
|
|
60
|
+
position: { left: 93.890625, top: 453.55381944444446 },
|
|
61
|
+
parameterMap: {
|
|
62
|
+
name: {
|
|
63
|
+
'5ntX0A6D5lObvGesm9kciW': {
|
|
64
|
+
key: '5ntX0A6D5lObvGesm9kciW',
|
|
65
|
+
type: 'VALUE',
|
|
66
|
+
expression: '',
|
|
67
|
+
order: 1,
|
|
68
|
+
value: 'count',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
schema: {
|
|
72
|
+
'1Se6m0293IcsOiFRKQlQen': {
|
|
73
|
+
key: '1Se6m0293IcsOiFRKQlQen',
|
|
74
|
+
type: 'VALUE',
|
|
75
|
+
expression: '',
|
|
76
|
+
order: 1,
|
|
77
|
+
value: { type: 'INTEGER' },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
set1: {
|
|
83
|
+
statementName: 'set1',
|
|
84
|
+
name: 'Set',
|
|
85
|
+
namespace: 'System.Context',
|
|
86
|
+
position: { left: 356.77951388888886, top: 633.9982638888889 },
|
|
87
|
+
parameterMap: {
|
|
88
|
+
name: {
|
|
89
|
+
'3QBReTdFoCDSMa7SBrjHje': {
|
|
90
|
+
key: '3QBReTdFoCDSMa7SBrjHje',
|
|
91
|
+
type: 'VALUE',
|
|
92
|
+
expression: '',
|
|
93
|
+
order: 1,
|
|
94
|
+
value: 'Context.count',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
value: {
|
|
98
|
+
'5Luu5FddZu8SYKOrgkdUoV': {
|
|
99
|
+
key: '5Luu5FddZu8SYKOrgkdUoV',
|
|
100
|
+
type: 'VALUE',
|
|
101
|
+
order: 1,
|
|
102
|
+
value: 0,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
dependentStatements: { 'Steps.create1.output': true },
|
|
107
|
+
},
|
|
108
|
+
generateEvent: {
|
|
109
|
+
statementName: 'generateEvent',
|
|
110
|
+
name: 'GenerateEvent',
|
|
111
|
+
namespace: 'System',
|
|
112
|
+
position: { left: 857.1128472222222, top: 1194.109375 },
|
|
113
|
+
parameterMap: {
|
|
114
|
+
results: {
|
|
115
|
+
'1Ddtjl1fJKLsUvZdr127RI': {
|
|
116
|
+
key: '1Ddtjl1fJKLsUvZdr127RI',
|
|
117
|
+
type: 'VALUE',
|
|
118
|
+
expression: '',
|
|
119
|
+
order: 1,
|
|
120
|
+
value: {
|
|
121
|
+
name: 'count',
|
|
122
|
+
value: { isExpression: true, value: 'Context.count' },
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
dependentStatements: { 'Steps.loop.output': true },
|
|
128
|
+
},
|
|
129
|
+
set: {
|
|
130
|
+
statementName: 'set',
|
|
131
|
+
name: 'Set',
|
|
132
|
+
namespace: 'System.Context',
|
|
133
|
+
position: { left: 332.6015625, top: 230.8984375 },
|
|
134
|
+
parameterMap: {
|
|
135
|
+
name: {
|
|
136
|
+
w8fhgGiU2OmUfqFAiTPh9: {
|
|
137
|
+
key: 'w8fhgGiU2OmUfqFAiTPh9',
|
|
138
|
+
type: 'VALUE',
|
|
139
|
+
expression: '',
|
|
140
|
+
order: 1,
|
|
141
|
+
value: 'Context.arr',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
value: {
|
|
145
|
+
'4dFnOUA9f80JhkqsKZJFvz': {
|
|
146
|
+
key: '4dFnOUA9f80JhkqsKZJFvz',
|
|
147
|
+
type: 'VALUE',
|
|
148
|
+
order: 1,
|
|
149
|
+
value: ['kiran', 'hi', '', '', 'hello', '', 'how'],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
dependentStatements: { 'Steps.create.output': true },
|
|
154
|
+
},
|
|
155
|
+
trim: {
|
|
156
|
+
statementName: 'trim',
|
|
157
|
+
name: 'Trim',
|
|
158
|
+
namespace: 'System.String',
|
|
159
|
+
position: { left: 907.1015625, top: 760.3984375 },
|
|
160
|
+
parameterMap: {
|
|
161
|
+
string: {
|
|
162
|
+
'7uvjy8hwDzlkIO6s8NLWr3': {
|
|
163
|
+
key: '7uvjy8hwDzlkIO6s8NLWr3',
|
|
164
|
+
type: 'EXPRESSION',
|
|
165
|
+
expression: 'Steps.loop.iteration.each',
|
|
166
|
+
order: 1,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
if: {
|
|
172
|
+
statementName: 'if',
|
|
173
|
+
name: 'If',
|
|
174
|
+
namespace: 'System',
|
|
175
|
+
position: { left: 1273.890625, top: 680.3315972222222 },
|
|
176
|
+
parameterMap: {
|
|
177
|
+
condition: {
|
|
178
|
+
'2rnqfOmJtOVK4RzhK0lPDu': {
|
|
179
|
+
key: '2rnqfOmJtOVK4RzhK0lPDu',
|
|
180
|
+
type: 'EXPRESSION',
|
|
181
|
+
expression: "Steps.trim.output.result != ''",
|
|
182
|
+
order: 1,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
set2: {
|
|
188
|
+
statementName: 'set2',
|
|
189
|
+
name: 'Set',
|
|
190
|
+
namespace: 'System.Context',
|
|
191
|
+
position: { left: 1833.6684027777778, top: 967.9982638888889 },
|
|
192
|
+
parameterMap: {
|
|
193
|
+
name: {
|
|
194
|
+
'7PMLUgrXK2AK1WqAPMsD4': {
|
|
195
|
+
key: '7PMLUgrXK2AK1WqAPMsD4',
|
|
196
|
+
type: 'VALUE',
|
|
197
|
+
expression: '',
|
|
198
|
+
order: 1,
|
|
199
|
+
value: 'Context.count',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
value: {
|
|
203
|
+
'1sbsvevDB8XQpFLvGE9Eoq': {
|
|
204
|
+
key: '1sbsvevDB8XQpFLvGE9Eoq',
|
|
205
|
+
type: 'EXPRESSION',
|
|
206
|
+
expression: 'Context.count + 1',
|
|
207
|
+
order: 1,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
dependentStatements: { 'Steps.if.true': true },
|
|
212
|
+
},
|
|
213
|
+
print: {
|
|
214
|
+
statementName: 'print',
|
|
215
|
+
name: 'Print',
|
|
216
|
+
namespace: 'System',
|
|
217
|
+
position: { left: 1493.2265625, top: 951.09375 },
|
|
218
|
+
parameterMap: {
|
|
219
|
+
values: {
|
|
220
|
+
'7GEehmufgT3pw3P6dAEkY7': {
|
|
221
|
+
key: '7GEehmufgT3pw3P6dAEkY7',
|
|
222
|
+
type: 'EXPRESSION',
|
|
223
|
+
expression: 'Steps.trim.output.result',
|
|
224
|
+
order: 1,
|
|
225
|
+
},
|
|
226
|
+
'5ESXu8zlY5wJLUzPt0ed5I': {
|
|
227
|
+
key: '5ESXu8zlY5wJLUzPt0ed5I',
|
|
228
|
+
type: 'EXPRESSION',
|
|
229
|
+
expression: 'Steps.loop.iteration.each',
|
|
230
|
+
order: 2,
|
|
231
|
+
},
|
|
232
|
+
'1Lghu5LxsX0DEDqLJmpzUY': {
|
|
233
|
+
key: '1Lghu5LxsX0DEDqLJmpzUY',
|
|
234
|
+
type: 'EXPRESSION',
|
|
235
|
+
order: 3,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
dependentStatements: { 'Steps.if.true': true },
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
namespace: '',
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const fd = FunctionDefinition.from(func);
|
|
246
|
+
|
|
247
|
+
const runtime = new KIRuntime(fd, false);
|
|
248
|
+
|
|
249
|
+
const oldConsole = console.log;
|
|
250
|
+
const test = (console.log = jest.fn().mockImplementation(() => {}));
|
|
251
|
+
|
|
252
|
+
const results = await runtime.execute(
|
|
253
|
+
new FunctionExecutionParameters(new KIRunFunctionRepository(), new KIRunSchemaRepository()),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
console.log = oldConsole;
|
|
257
|
+
expect(results.allResults()[0].getResult().get('count')).toBe(4);
|
|
258
|
+
expect(test.mock.calls.length).toBe(4);
|
|
259
|
+
});
|