@fincity/kirun-js 1.6.11 → 1.6.12
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/ArrayToArrayOfObjectsTest.ts +146 -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/ArrayFunctionRepository.ts +2 -0
- package/src/engine/function/system/array/ArrayToArrayOfObjects.ts +62 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionExecutionParameters,
|
|
3
|
+
KIRunFunctionRepository,
|
|
4
|
+
KIRunSchemaRepository,
|
|
5
|
+
} from '../../../../../src';
|
|
6
|
+
import { ArrayToArrayOfObjects } from '../../../../../src/engine/function/system/array/ArrayToArrayOfObjects';
|
|
7
|
+
|
|
8
|
+
test('Array to Array of objects', async () => {
|
|
9
|
+
let fun = new ArrayToArrayOfObjects();
|
|
10
|
+
|
|
11
|
+
let result = (
|
|
12
|
+
await fun.execute(
|
|
13
|
+
new FunctionExecutionParameters(
|
|
14
|
+
new KIRunFunctionRepository(),
|
|
15
|
+
new KIRunSchemaRepository(),
|
|
16
|
+
).setArguments(new Map([['source', [1, 2, 3]]])),
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
.allResults()[0]
|
|
20
|
+
.getResult()
|
|
21
|
+
.get('output');
|
|
22
|
+
|
|
23
|
+
expect(result).toMatchObject([{ value: 1 }, { value: 2 }, { value: 3 }]);
|
|
24
|
+
|
|
25
|
+
result = (
|
|
26
|
+
await fun.execute(
|
|
27
|
+
new FunctionExecutionParameters(
|
|
28
|
+
new KIRunFunctionRepository(),
|
|
29
|
+
new KIRunSchemaRepository(),
|
|
30
|
+
).setArguments(
|
|
31
|
+
new Map([
|
|
32
|
+
['source', [1, 2, 3]],
|
|
33
|
+
['keyName', ['number']],
|
|
34
|
+
]),
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
.allResults()[0]
|
|
39
|
+
.getResult()
|
|
40
|
+
.get('output');
|
|
41
|
+
|
|
42
|
+
expect(result).toMatchObject([{ number: 1 }, { number: 2 }, { number: 3 }]);
|
|
43
|
+
|
|
44
|
+
result = (
|
|
45
|
+
await fun.execute(
|
|
46
|
+
new FunctionExecutionParameters(
|
|
47
|
+
new KIRunFunctionRepository(),
|
|
48
|
+
new KIRunSchemaRepository(),
|
|
49
|
+
).setArguments(new Map([['source', [{ number: 1 }, { number: 2 }, { number: 3 }]]])),
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
.allResults()[0]
|
|
53
|
+
.getResult()
|
|
54
|
+
.get('output');
|
|
55
|
+
|
|
56
|
+
expect(result).toMatchObject([
|
|
57
|
+
{ value: { number: 1 } },
|
|
58
|
+
{ value: { number: 2 } },
|
|
59
|
+
{ value: { number: 3 } },
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
result = (
|
|
63
|
+
await fun.execute(
|
|
64
|
+
new FunctionExecutionParameters(
|
|
65
|
+
new KIRunFunctionRepository(),
|
|
66
|
+
new KIRunSchemaRepository(),
|
|
67
|
+
).setArguments(
|
|
68
|
+
new Map([
|
|
69
|
+
[
|
|
70
|
+
'source',
|
|
71
|
+
[
|
|
72
|
+
['a', 1],
|
|
73
|
+
['b', 2],
|
|
74
|
+
['c', '3'],
|
|
75
|
+
],
|
|
76
|
+
],
|
|
77
|
+
]),
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
.allResults()[0]
|
|
82
|
+
.getResult()
|
|
83
|
+
.get('output');
|
|
84
|
+
|
|
85
|
+
expect(result).toMatchObject([
|
|
86
|
+
{ value1: 'a', value2: 1 },
|
|
87
|
+
{ value1: 'b', value2: 2 },
|
|
88
|
+
{ value1: 'c', value2: '3' },
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
result = (
|
|
92
|
+
await fun.execute(
|
|
93
|
+
new FunctionExecutionParameters(
|
|
94
|
+
new KIRunFunctionRepository(),
|
|
95
|
+
new KIRunSchemaRepository(),
|
|
96
|
+
).setArguments(
|
|
97
|
+
new Map([
|
|
98
|
+
[
|
|
99
|
+
'source',
|
|
100
|
+
[
|
|
101
|
+
['a', 1],
|
|
102
|
+
['b', 2],
|
|
103
|
+
['c', '3'],
|
|
104
|
+
],
|
|
105
|
+
],
|
|
106
|
+
['keyName', ['key', 'value', 'other']],
|
|
107
|
+
]),
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
.allResults()[0]
|
|
112
|
+
.getResult()
|
|
113
|
+
.get('output');
|
|
114
|
+
|
|
115
|
+
expect(result).toMatchObject([
|
|
116
|
+
{ key: 'a', value: 1 },
|
|
117
|
+
{ key: 'b', value: 2 },
|
|
118
|
+
{ key: 'c', value: '3' },
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
result = (
|
|
122
|
+
await fun.execute(
|
|
123
|
+
new FunctionExecutionParameters(
|
|
124
|
+
new KIRunFunctionRepository(),
|
|
125
|
+
new KIRunSchemaRepository(),
|
|
126
|
+
).setArguments(
|
|
127
|
+
new Map([
|
|
128
|
+
[
|
|
129
|
+
'source',
|
|
130
|
+
[
|
|
131
|
+
['a', 1],
|
|
132
|
+
['b', 2],
|
|
133
|
+
['c', '3'],
|
|
134
|
+
],
|
|
135
|
+
],
|
|
136
|
+
['keyName', ['maKey']],
|
|
137
|
+
]),
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
.allResults()[0]
|
|
142
|
+
.getResult()
|
|
143
|
+
.get('output');
|
|
144
|
+
|
|
145
|
+
expect(result).toMatchObject([{ maKey: 'a' }, { maKey: 'b' }, { maKey: 'c' }]);
|
|
146
|
+
});
|