@fincity/kirun-js 2.0.3 → 2.0.5
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.
- package/__tests__/engine/function/system/array/SortTest.ts +103 -6
- package/__tests__/engine/function/system/string/StringFunctionRepoTest4.ts +55 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/system/array/AbstractArrayFunction.ts +6 -1
- package/src/engine/function/system/array/Sort.ts +20 -5
- package/src/engine/function/system/string/StringFunctionRepository.ts +1 -1
|
@@ -53,9 +53,9 @@ test('sort test 2', async () => {
|
|
|
53
53
|
|
|
54
54
|
let res: any[] = [];
|
|
55
55
|
res.push(12);
|
|
56
|
-
res.push(1);
|
|
57
|
-
res.push(15);
|
|
58
56
|
res.push(98);
|
|
57
|
+
res.push(15);
|
|
58
|
+
res.push(1);
|
|
59
59
|
|
|
60
60
|
expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toStrictEqual(res);
|
|
61
61
|
});
|
|
@@ -72,10 +72,10 @@ test('sort test 3', async () => {
|
|
|
72
72
|
let res: any[] = [];
|
|
73
73
|
res.push(12);
|
|
74
74
|
res.push(15);
|
|
75
|
-
res.push('sure');
|
|
76
|
-
res.push('c');
|
|
77
|
-
res.push(98);
|
|
78
75
|
res.push(1);
|
|
76
|
+
res.push(98);
|
|
77
|
+
res.push('c');
|
|
78
|
+
res.push('sure');
|
|
79
79
|
|
|
80
80
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
81
81
|
new KIRunFunctionRepository(),
|
|
@@ -121,7 +121,7 @@ test('sort test 4', async () => {
|
|
|
121
121
|
new Map<string, any>([
|
|
122
122
|
[Sort.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr],
|
|
123
123
|
[Sort.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
124
|
-
[Sort.PARAMETER_BOOLEAN_ASCENDING.getParameterName(),
|
|
124
|
+
[Sort.PARAMETER_BOOLEAN_ASCENDING.getParameterName(), false],
|
|
125
125
|
]),
|
|
126
126
|
);
|
|
127
127
|
|
|
@@ -144,3 +144,100 @@ test('sort test 5', async () => {
|
|
|
144
144
|
let res: any[] = ['Banana', 'Apple', 'Mango', 'Orange'];
|
|
145
145
|
expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res);
|
|
146
146
|
});
|
|
147
|
+
|
|
148
|
+
test('sort test 6', async () => {
|
|
149
|
+
let arr: any[] = [
|
|
150
|
+
{ order: 13 },
|
|
151
|
+
{ order: 3 },
|
|
152
|
+
{ order: 130 },
|
|
153
|
+
{ order: 10 },
|
|
154
|
+
{ order: 21 },
|
|
155
|
+
{ order: 1 },
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
159
|
+
new KIRunFunctionRepository(),
|
|
160
|
+
new KIRunSchemaRepository(),
|
|
161
|
+
).setArguments(
|
|
162
|
+
new Map<string, any>([
|
|
163
|
+
[Sort.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr],
|
|
164
|
+
[Sort.PARAMETER_INT_FIND_FROM.getParameterName(), 0],
|
|
165
|
+
[Sort.PARAMETER_INT_LENGTH.getParameterName(), arr.length],
|
|
166
|
+
[Sort.PARAMETER_KEY_PATH.getParameterName(), 'order'],
|
|
167
|
+
]),
|
|
168
|
+
);
|
|
169
|
+
let res: any[] = [
|
|
170
|
+
{ order: 1 },
|
|
171
|
+
{ order: 3 },
|
|
172
|
+
{ order: 10 },
|
|
173
|
+
{ order: 13 },
|
|
174
|
+
{ order: 21 },
|
|
175
|
+
{ order: 130 },
|
|
176
|
+
];
|
|
177
|
+
expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('sort test 7', async () => {
|
|
181
|
+
let arr: any[] = [
|
|
182
|
+
{ order: { order: 13 } },
|
|
183
|
+
{ order: { order: 3 } },
|
|
184
|
+
{ order: { order: 130 } },
|
|
185
|
+
{ order: { order: 10 } },
|
|
186
|
+
{ order: { order: 21 } },
|
|
187
|
+
{ order: { order: 1 } },
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
191
|
+
new KIRunFunctionRepository(),
|
|
192
|
+
new KIRunSchemaRepository(),
|
|
193
|
+
).setArguments(
|
|
194
|
+
new Map<string, any>([
|
|
195
|
+
[Sort.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr],
|
|
196
|
+
[Sort.PARAMETER_INT_FIND_FROM.getParameterName(), 0],
|
|
197
|
+
[Sort.PARAMETER_INT_LENGTH.getParameterName(), arr.length],
|
|
198
|
+
[Sort.PARAMETER_KEY_PATH.getParameterName(), 'order.order'],
|
|
199
|
+
]),
|
|
200
|
+
);
|
|
201
|
+
let res: any[] = [
|
|
202
|
+
{ order: { order: 1 } },
|
|
203
|
+
{ order: { order: 3 } },
|
|
204
|
+
{ order: { order: 10 } },
|
|
205
|
+
{ order: { order: 13 } },
|
|
206
|
+
{ order: { order: 21 } },
|
|
207
|
+
{ order: { order: 130 } },
|
|
208
|
+
];
|
|
209
|
+
expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('sort test 8', async () => {
|
|
213
|
+
let arr: any[] = [
|
|
214
|
+
{ order: { order: 13 } },
|
|
215
|
+
{ order: { order: 3 } },
|
|
216
|
+
{ order: { order: 130 } },
|
|
217
|
+
{ order: { order: 10 } },
|
|
218
|
+
{ order: { order: 21 } },
|
|
219
|
+
{ order: { order: 1 } },
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
223
|
+
new KIRunFunctionRepository(),
|
|
224
|
+
new KIRunSchemaRepository(),
|
|
225
|
+
).setArguments(
|
|
226
|
+
new Map<string, any>([
|
|
227
|
+
[Sort.PARAMETER_ARRAY_SOURCE_PRIMITIVE.getParameterName(), arr],
|
|
228
|
+
[Sort.PARAMETER_INT_FIND_FROM.getParameterName(), 0],
|
|
229
|
+
[Sort.PARAMETER_INT_LENGTH.getParameterName(), arr.length],
|
|
230
|
+
[Sort.PARAMETER_KEY_PATH.getParameterName(), 'order.order'],
|
|
231
|
+
[Sort.PARAMETER_BOOLEAN_ASCENDING.getParameterName(), false],
|
|
232
|
+
]),
|
|
233
|
+
);
|
|
234
|
+
let res: any[] = [
|
|
235
|
+
{ order: { order: 130 } },
|
|
236
|
+
{ order: { order: 21 } },
|
|
237
|
+
{ order: { order: 13 } },
|
|
238
|
+
{ order: { order: 10 } },
|
|
239
|
+
{ order: { order: 3 } },
|
|
240
|
+
{ order: { order: 1 } },
|
|
241
|
+
];
|
|
242
|
+
expect((await sort.execute(fep)).allResults()[0].getResult().get('result')).toMatchObject(res);
|
|
243
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
2
|
+
import { AbstractStringFunction } from '../../../../../src/engine/function/system/string/AbstractStringFunction';
|
|
3
|
+
import { StringFunctionRepository } from '../../../../../src/engine/function/system/string/StringFunctionRepository';
|
|
4
|
+
import { Namespaces } from '../../../../../src/engine/namespaces/Namespaces';
|
|
5
|
+
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
6
|
+
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
7
|
+
|
|
8
|
+
const repo = new StringFunctionRepository();
|
|
9
|
+
|
|
10
|
+
test('StringFunctionRepository - Replace', async () => {
|
|
11
|
+
let fun = await repo.find(Namespaces.STRING, 'Replace');
|
|
12
|
+
|
|
13
|
+
if (!fun) {
|
|
14
|
+
throw new Error('Function not available');
|
|
15
|
+
}
|
|
16
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
17
|
+
new KIRunFunctionRepository(),
|
|
18
|
+
new KIRunSchemaRepository(),
|
|
19
|
+
);
|
|
20
|
+
fep.setArguments(
|
|
21
|
+
MapUtil.of(
|
|
22
|
+
AbstractStringFunction.PARAMETER_STRING_NAME,
|
|
23
|
+
' new elemenet ',
|
|
24
|
+
AbstractStringFunction.PARAMETER_SECOND_STRING_NAME,
|
|
25
|
+
' ',
|
|
26
|
+
AbstractStringFunction.PARAMETER_THIRD_STRING_NAME,
|
|
27
|
+
'',
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(
|
|
32
|
+
(await fun.execute(fep))
|
|
33
|
+
.allResults()[0]
|
|
34
|
+
.getResult()
|
|
35
|
+
.get(AbstractStringFunction.EVENT_RESULT_NAME),
|
|
36
|
+
).toBe('newelemenet');
|
|
37
|
+
|
|
38
|
+
fep.setArguments(
|
|
39
|
+
MapUtil.of(
|
|
40
|
+
AbstractStringFunction.PARAMETER_STRING_NAME,
|
|
41
|
+
'thereisnospace',
|
|
42
|
+
AbstractStringFunction.PARAMETER_SECOND_STRING_NAME,
|
|
43
|
+
' ',
|
|
44
|
+
AbstractStringFunction.PARAMETER_THIRD_STRING_NAME,
|
|
45
|
+
' ',
|
|
46
|
+
),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
(await fun.execute(fep))
|
|
51
|
+
.allResults()[0]
|
|
52
|
+
.getResult()
|
|
53
|
+
.get(AbstractStringFunction.EVENT_RESULT_NAME),
|
|
54
|
+
).toBe('thereisnospace');
|
|
55
|
+
});
|