@fincity/kirun-js 2.7.0 → 2.8.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.
- package/__tests__/engine/function/system/WaitTest.ts +1 -1
- package/__tests__/engine/function/system/array/AddFirstTest.ts +2 -6
- package/__tests__/engine/function/system/array/IndexOfTest.ts +8 -13
- package/__tests__/engine/function/system/array/LastIndexOfTest.ts +9 -28
- package/__tests__/engine/function/system/date/AddSubtractTimeTest.ts +93 -0
- package/__tests__/engine/function/system/date/DateFunctionRepositoryTest.ts +96 -0
- package/__tests__/engine/function/system/date/DifferenceTest.ts +93 -0
- package/__tests__/engine/function/system/date/EpochToTimestampTest.ts +133 -0
- package/__tests__/engine/function/system/date/FromDateStringTest.ts +51 -0
- package/__tests__/engine/function/system/date/FromNowTest.ts +71 -0
- package/__tests__/engine/function/system/date/GetCurrentTimeStampTest.ts +19 -27
- package/__tests__/engine/function/system/date/GetNamesTest.ts +105 -0
- package/__tests__/engine/function/system/date/IsBetweenTest.ts +53 -0
- package/__tests__/engine/function/system/date/IsValidISODateTest.ts +42 -54
- package/__tests__/engine/function/system/date/LastFirstOfTest.ts +64 -0
- package/__tests__/engine/function/system/date/SetTimeZoneTest.ts +48 -0
- package/__tests__/engine/function/system/date/StartEndOfTest.ts +53 -0
- package/__tests__/engine/function/system/date/TimeAsTest.ts +24 -0
- package/__tests__/engine/function/system/date/TimestampToEpochTest.ts +45 -0
- package/__tests__/engine/function/system/date/ToDateStringTest.ts +48 -0
- package/__tests__/engine/function/system/math/RandomFloatTest.ts +21 -22
- package/__tests__/engine/function/system/math/RandomIntTest.ts +5 -4
- package/__tests__/engine/repository/RepositoryFilterTest.ts +4 -1
- package/__tests__/engine/runtime/expression/ExpressionEqualityTest.ts +76 -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 +14 -13
- package/dist/types.d.ts.map +1 -1
- package/generator/generateValidationCSV.ts +51 -42
- package/generator/validation-js.csv +0 -0
- package/package.json +9 -7
- package/src/engine/function/AbstractFunction.ts +1 -1
- package/src/engine/function/system/Print.ts +19 -5
- package/src/engine/function/system/Wait.ts +1 -1
- package/src/engine/function/system/array/AbstractArrayFunction.ts +3 -3
- package/src/engine/function/system/array/Fill.ts +1 -1
- package/src/engine/function/system/array/Frequency.ts +0 -1
- package/src/engine/function/system/array/IndexOf.ts +4 -4
- package/src/engine/function/system/array/LastIndexOf.ts +3 -3
- package/src/engine/function/system/array/Rotate.ts +1 -1
- package/src/engine/function/system/array/Shuffle.ts +1 -1
- package/src/engine/function/system/array/Sort.ts +1 -1
- package/src/engine/function/system/date/AbstractDateFunction.ts +229 -111
- package/src/engine/function/system/date/AddSubtractTime.ts +99 -0
- package/src/engine/function/system/date/DateFunctionRepository.ts +228 -122
- package/src/engine/function/system/date/EpochToTimestamp.ts +75 -0
- package/src/engine/function/system/date/FromDateString.ts +44 -0
- package/src/engine/function/system/date/FromNow.ts +77 -0
- package/src/engine/function/system/date/GetCurrent.ts +20 -0
- package/src/engine/function/system/date/GetNames.ts +74 -0
- package/src/engine/function/system/date/IsBetween.ts +62 -0
- package/src/engine/function/system/date/IsValidISODate.ts +54 -40
- package/src/engine/function/system/date/LastFirstOf.ts +72 -0
- package/src/engine/function/system/date/SetTimeZone.ts +43 -0
- package/src/engine/function/system/date/StartEndOf.ts +44 -0
- package/src/engine/function/system/date/TimeAs.ts +64 -0
- package/src/engine/function/system/date/TimestampToEpoch.ts +54 -0
- package/src/engine/function/system/date/ToDateString.ts +49 -0
- package/src/engine/function/system/date/common.ts +9 -0
- package/src/engine/function/system/math/MathFunctionRepository.ts +43 -4
- package/src/engine/function/system/math/RandomAny.ts +57 -0
- package/src/engine/function/system/object/ObjectConvert.ts +45 -19
- package/src/engine/function/system/object/ObjectFunctionRepository.ts +2 -1
- package/src/engine/function/system/string/AbstractStringFunction.ts +42 -82
- package/src/engine/function/system/string/StringFunctionRepository.ts +39 -20
- package/src/engine/json/schema/SchemaUtil.ts +1 -1
- package/src/engine/repository/KIRunSchemaRepository.ts +57 -3
- package/src/engine/util/string/StringUtil.ts +12 -0
- package/tsconfig.json +1 -2
- package/__tests__/engine/function/system/date/AddTimeTest.ts +0 -115
- package/__tests__/engine/function/system/date/DateToEpochTest.ts +0 -74
- package/__tests__/engine/function/system/date/DifferenceOfTimestampsTest.ts +0 -53
- package/__tests__/engine/function/system/date/EpochToDateTest.ts +0 -105
- package/__tests__/engine/function/system/date/GetDateTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetDayTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetFullYearTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetHoursTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMilliSecondsTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMinutesTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMonthTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetSecondsTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetTimeAsArrayTest.ts +0 -59
- package/__tests__/engine/function/system/date/GetTimeAsObjectTest.ts +0 -83
- package/__tests__/engine/function/system/date/GetTimeTest.ts +0 -86
- package/__tests__/engine/function/system/date/IsLeapYearTest.ts +0 -85
- package/__tests__/engine/function/system/date/MaximumTimestampTest.ts +0 -55
- package/__tests__/engine/function/system/date/MinimumTimestampTest.ts +0 -54
- package/__tests__/engine/function/system/date/SubtractTimeTest.ts +0 -95
- package/src/engine/function/system/date/DateToEpoch.ts +0 -39
- package/src/engine/function/system/date/DifferenceOfTimestamps.ts +0 -45
- package/src/engine/function/system/date/EpochToDate.ts +0 -76
- package/src/engine/function/system/date/GetCurrentTimeStamp.ts +0 -36
- package/src/engine/function/system/date/GetTimeAsArray.ts +0 -48
- package/src/engine/function/system/date/GetTimeAsObject.ts +0 -66
- package/src/engine/function/system/date/MaximumTimestamp.ts +0 -73
- package/src/engine/function/system/date/MinimumTimestamp.ts +0 -74
- package/src/engine/function/system/math/RandomFloat.ts +0 -56
- package/src/engine/function/system/math/RandomInt.ts +0 -56
|
@@ -42,7 +42,7 @@ test('wait test immediately', async () => {
|
|
|
42
42
|
await waitFunction.execute(fep.setArguments(new Map()));
|
|
43
43
|
|
|
44
44
|
const endTime = new Date().getTime();
|
|
45
|
-
expect(endTime - startTime).toBeLessThan(
|
|
45
|
+
expect(endTime - startTime).toBeLessThan(50);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
test('wait test error with negative number', async () => {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
KIRunFunctionRepository,
|
|
3
|
-
KIRunSchemaRepository,
|
|
4
|
-
SchemaValidationException,
|
|
5
|
-
} from '../../../../../src';
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
6
2
|
import { AddFirst } from '../../../../../src/engine/function/system/array/AddFirst';
|
|
7
3
|
|
|
8
4
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
@@ -225,7 +221,7 @@ test('Add Test 4', async () => {
|
|
|
225
221
|
.setArguments(
|
|
226
222
|
new Map([
|
|
227
223
|
[AddFirst.PARAMETER_ARRAY_SOURCE.getParameterName(), null],
|
|
228
|
-
[AddFirst.
|
|
224
|
+
[AddFirst.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), temp],
|
|
229
225
|
]),
|
|
230
226
|
)
|
|
231
227
|
.setSteps(new Map([]))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
1
2
|
import { IndexOf } from '../../../../../src/engine/function/system/array/IndexOf';
|
|
2
3
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
-
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
4
|
|
|
5
5
|
test('Index of Test 1', async () => {
|
|
6
6
|
let ind: IndexOf = new IndexOf();
|
|
@@ -32,7 +32,7 @@ test('Index of Test 1', async () => {
|
|
|
32
32
|
).setArguments(
|
|
33
33
|
new Map<string, any>([
|
|
34
34
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
35
|
-
[IndexOf.
|
|
35
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
36
36
|
[IndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
37
37
|
]),
|
|
38
38
|
);
|
|
@@ -71,7 +71,7 @@ test('Index of Test 2', async () => {
|
|
|
71
71
|
).setArguments(
|
|
72
72
|
new Map<string, any>([
|
|
73
73
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
74
|
-
[IndexOf.
|
|
74
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
75
75
|
[IndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), -2],
|
|
76
76
|
]),
|
|
77
77
|
);
|
|
@@ -81,7 +81,7 @@ test('Index of Test 2', async () => {
|
|
|
81
81
|
fep.setArguments(
|
|
82
82
|
new Map<string, any>([
|
|
83
83
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), []],
|
|
84
|
-
[IndexOf.
|
|
84
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
85
85
|
[IndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), -2],
|
|
86
86
|
]),
|
|
87
87
|
);
|
|
@@ -120,7 +120,7 @@ test('Index of Test 3', async () => {
|
|
|
120
120
|
).setArguments(
|
|
121
121
|
new Map<string, any>([
|
|
122
122
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
123
|
-
[IndexOf.
|
|
123
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
124
124
|
[IndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 0],
|
|
125
125
|
]),
|
|
126
126
|
);
|
|
@@ -213,7 +213,7 @@ test('Index of Test 4', async () => {
|
|
|
213
213
|
).setArguments(
|
|
214
214
|
new Map<string, any>([
|
|
215
215
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), arr],
|
|
216
|
-
[IndexOf.
|
|
216
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
217
217
|
[IndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
218
218
|
]),
|
|
219
219
|
);
|
|
@@ -265,7 +265,7 @@ test('indexof test 5', async () => {
|
|
|
265
265
|
).setArguments(
|
|
266
266
|
new Map<string, any>([
|
|
267
267
|
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), arr],
|
|
268
|
-
[IndexOf.
|
|
268
|
+
[IndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
269
269
|
]),
|
|
270
270
|
);
|
|
271
271
|
|
|
@@ -273,11 +273,6 @@ test('indexof test 5', async () => {
|
|
|
273
273
|
(await ind.execute(fep)).allResults()[0].getResult().get(IndexOf.EVENT_RESULT_NAME),
|
|
274
274
|
).toBe(5);
|
|
275
275
|
|
|
276
|
-
fep.setArguments(
|
|
277
|
-
new Map<string, any>([
|
|
278
|
-
[IndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), arr],
|
|
279
|
-
[IndexOf.PARAMETER_ANY_NOT_NULL.getParameterName(), null],
|
|
280
|
-
]),
|
|
281
|
-
);
|
|
276
|
+
fep.setArguments(new Map<string, any>());
|
|
282
277
|
await expect(ind.execute(fep)).rejects.toThrow();
|
|
283
278
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
1
2
|
import { LastIndexOf } from '../../../../../src/engine/function/system/array/LastIndexOf';
|
|
2
3
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
-
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
4
|
|
|
5
5
|
test('Last Index of Test 1', async () => {
|
|
6
6
|
let lind: LastIndexOf = new LastIndexOf();
|
|
@@ -32,7 +32,7 @@ test('Last Index of Test 1', async () => {
|
|
|
32
32
|
).setArguments(
|
|
33
33
|
new Map<string, any>([
|
|
34
34
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
35
|
-
[LastIndexOf.
|
|
35
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
36
36
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
37
37
|
]),
|
|
38
38
|
);
|
|
@@ -71,8 +71,8 @@ test('Last Index of Test 2', async () => {
|
|
|
71
71
|
).setArguments(
|
|
72
72
|
new Map<string, any>([
|
|
73
73
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
74
|
-
[LastIndexOf.
|
|
75
|
-
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
74
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
75
|
+
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), -2],
|
|
76
76
|
]),
|
|
77
77
|
);
|
|
78
78
|
await expect(lind.execute(fep)).rejects.toThrow();
|
|
@@ -81,25 +81,6 @@ test('Last Index of Test 2', async () => {
|
|
|
81
81
|
test('Last Index of Test 3', async () => {
|
|
82
82
|
let lind: LastIndexOf = new LastIndexOf();
|
|
83
83
|
|
|
84
|
-
let array: string[] = [];
|
|
85
|
-
|
|
86
|
-
array.push('test');
|
|
87
|
-
array.push('Driven');
|
|
88
|
-
array.push('developement');
|
|
89
|
-
array.push('I');
|
|
90
|
-
array.push('am');
|
|
91
|
-
array.push('using');
|
|
92
|
-
array.push('eclipse');
|
|
93
|
-
array.push('I');
|
|
94
|
-
array.push('to');
|
|
95
|
-
array.push('test');
|
|
96
|
-
array.push('the');
|
|
97
|
-
array.push('changes');
|
|
98
|
-
array.push('with');
|
|
99
|
-
array.push('test');
|
|
100
|
-
array.push('Driven');
|
|
101
|
-
array.push('developement');
|
|
102
|
-
|
|
103
84
|
let find;
|
|
104
85
|
|
|
105
86
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
@@ -108,7 +89,7 @@ test('Last Index of Test 3', async () => {
|
|
|
108
89
|
).setArguments(
|
|
109
90
|
new Map<string, any>([
|
|
110
91
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), null],
|
|
111
|
-
[LastIndexOf.
|
|
92
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
112
93
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 2],
|
|
113
94
|
]),
|
|
114
95
|
);
|
|
@@ -145,7 +126,7 @@ test('Last Index of Test 4', async () => {
|
|
|
145
126
|
).setArguments(
|
|
146
127
|
new Map<string, any>([
|
|
147
128
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
148
|
-
[LastIndexOf.
|
|
129
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
149
130
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 12],
|
|
150
131
|
]),
|
|
151
132
|
);
|
|
@@ -156,7 +137,7 @@ test('Last Index of Test 4', async () => {
|
|
|
156
137
|
fep.setArguments(
|
|
157
138
|
new Map<string, any>([
|
|
158
139
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
159
|
-
[LastIndexOf.
|
|
140
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), 'newas'],
|
|
160
141
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 12],
|
|
161
142
|
]),
|
|
162
143
|
);
|
|
@@ -195,7 +176,7 @@ test('Last Index of Test 5', async () => {
|
|
|
195
176
|
).setArguments(
|
|
196
177
|
new Map<string, any>([
|
|
197
178
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), array],
|
|
198
|
-
[LastIndexOf.
|
|
179
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), find],
|
|
199
180
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), -2],
|
|
200
181
|
]),
|
|
201
182
|
);
|
|
@@ -250,7 +231,7 @@ test('Last Index of Test 6', async () => {
|
|
|
250
231
|
).setArguments(
|
|
251
232
|
new Map<string, any>([
|
|
252
233
|
[LastIndexOf.PARAMETER_ARRAY_SOURCE.getParameterName(), arr],
|
|
253
|
-
[LastIndexOf.
|
|
234
|
+
[LastIndexOf.PARAMETER_ANY_ELEMENT_OBJECT.getParameterName(), js4],
|
|
254
235
|
[LastIndexOf.PARAMETER_INT_FIND_FROM.getParameterName(), 1],
|
|
255
236
|
]),
|
|
256
237
|
);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DateTime, Settings } from 'luxon';
|
|
2
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
3
|
+
import { AbstractDateFunction } from '../../../../../src/engine/function/system/date/AbstractDateFunction';
|
|
4
|
+
import { AddSubtractTime } from '../../../../../src/engine/function/system/date/AddSubtractTime';
|
|
5
|
+
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
6
|
+
|
|
7
|
+
const addFunction = new AddSubtractTime(true);
|
|
8
|
+
const subtractFunction = new AddSubtractTime(false);
|
|
9
|
+
|
|
10
|
+
Settings.defaultZone = 'Asia/Kolkata';
|
|
11
|
+
|
|
12
|
+
describe('AddSubtractTime', () => {
|
|
13
|
+
test('should add time with no values', async () => {
|
|
14
|
+
const fep = new FunctionExecutionParameters(
|
|
15
|
+
new KIRunFunctionRepository(),
|
|
16
|
+
new KIRunSchemaRepository(),
|
|
17
|
+
).setArguments(
|
|
18
|
+
new Map<string, any>([
|
|
19
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2025-01-01T10:20:35+05:30'],
|
|
20
|
+
]),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const result = await addFunction.execute(fep);
|
|
24
|
+
|
|
25
|
+
expect(
|
|
26
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_TIMESTAMP_NAME),
|
|
27
|
+
).toBe('2025-01-01T10:20:35.000+05:30');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('shoudl subtract time with no values', async () => {
|
|
31
|
+
const fep = new FunctionExecutionParameters(
|
|
32
|
+
new KIRunFunctionRepository(),
|
|
33
|
+
new KIRunSchemaRepository(),
|
|
34
|
+
).setArguments(
|
|
35
|
+
new Map<string, any>([
|
|
36
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2025-01-01T10:20:35+05:30'],
|
|
37
|
+
]),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const result = await subtractFunction.execute(fep);
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_TIMESTAMP_NAME),
|
|
44
|
+
).toBe('2025-01-01T10:20:35.000+05:30');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('should add time with all values', async () => {
|
|
48
|
+
const fep = new FunctionExecutionParameters(
|
|
49
|
+
new KIRunFunctionRepository(),
|
|
50
|
+
new KIRunSchemaRepository(),
|
|
51
|
+
).setArguments(
|
|
52
|
+
new Map<string, any>([
|
|
53
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2025-01-01T10:20:35+05:30'],
|
|
54
|
+
[AddSubtractTime.PARAMETER_YEARS_NAME, 1],
|
|
55
|
+
[AddSubtractTime.PARAMETER_MONTHS_NAME, 1],
|
|
56
|
+
[AddSubtractTime.PARAMETER_DAYS_NAME, 1],
|
|
57
|
+
[AddSubtractTime.PARAMETER_HOURS_NAME, 1],
|
|
58
|
+
[AddSubtractTime.PARAMETER_MINUTES_NAME, 1],
|
|
59
|
+
[AddSubtractTime.PARAMETER_SECONDS_NAME, 1],
|
|
60
|
+
]),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const result = await addFunction.execute(fep);
|
|
64
|
+
|
|
65
|
+
expect(
|
|
66
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_TIMESTAMP_NAME),
|
|
67
|
+
).toBe('2026-02-02T11:21:36.000+05:30');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('should subtract time with all values', async () => {
|
|
71
|
+
const fep = new FunctionExecutionParameters(
|
|
72
|
+
new KIRunFunctionRepository(),
|
|
73
|
+
new KIRunSchemaRepository(),
|
|
74
|
+
).setArguments(
|
|
75
|
+
new Map<string, any>([
|
|
76
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2025-01-01T10:20:35+05:30'],
|
|
77
|
+
[AddSubtractTime.PARAMETER_YEARS_NAME, 1],
|
|
78
|
+
[AddSubtractTime.PARAMETER_MONTHS_NAME, 1],
|
|
79
|
+
[AddSubtractTime.PARAMETER_DAYS_NAME, 1],
|
|
80
|
+
[AddSubtractTime.PARAMETER_HOURS_NAME, 1],
|
|
81
|
+
[AddSubtractTime.PARAMETER_MINUTES_NAME, 1],
|
|
82
|
+
[AddSubtractTime.PARAMETER_SECONDS_NAME, 1],
|
|
83
|
+
[AddSubtractTime.PARAMETER_MILLISECONDS_NAME, 8],
|
|
84
|
+
]),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const result = await subtractFunction.execute(fep);
|
|
88
|
+
|
|
89
|
+
expect(
|
|
90
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_TIMESTAMP_NAME),
|
|
91
|
+
).toBe('2023-11-30T09:19:33.992+05:30');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Settings } from 'luxon';
|
|
2
|
+
import { Namespaces } from '../../../../../src';
|
|
3
|
+
import { AbstractDateFunction } from '../../../../../src/engine/function/system/date/AbstractDateFunction';
|
|
4
|
+
import { DateFunctionRepository } from '../../../../../src/engine/function/system/date/DateFunctionRepository';
|
|
5
|
+
import { KIRunFunctionRepository } from '../../../../../src/engine/repository/KIRunFunctionRepository';
|
|
6
|
+
import { KIRunSchemaRepository } from '../../../../../src/engine/repository/KIRunSchemaRepository';
|
|
7
|
+
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
8
|
+
|
|
9
|
+
const repo = new DateFunctionRepository();
|
|
10
|
+
|
|
11
|
+
Settings.defaultZone = 'Asia/Kolkata';
|
|
12
|
+
|
|
13
|
+
describe('DateFunctionRepository', () => {
|
|
14
|
+
test('should return Date by using GetDate', async () => {
|
|
15
|
+
const fep = new FunctionExecutionParameters(
|
|
16
|
+
new KIRunFunctionRepository(),
|
|
17
|
+
new KIRunSchemaRepository(),
|
|
18
|
+
).setArguments(new Map([[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2024-01-01']]));
|
|
19
|
+
|
|
20
|
+
const result = (await (await repo.find(Namespaces.DATE, 'GetDay'))!.execute(fep))
|
|
21
|
+
.allResults()[0]
|
|
22
|
+
.getResult()
|
|
23
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
24
|
+
expect(result).toBe(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('should return the days in month using GetDaysInMonth', async () => {
|
|
28
|
+
const fep = new FunctionExecutionParameters(
|
|
29
|
+
new KIRunFunctionRepository(),
|
|
30
|
+
new KIRunSchemaRepository(),
|
|
31
|
+
).setArguments(new Map([[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2024-01-01']]));
|
|
32
|
+
|
|
33
|
+
const result = (await (await repo.find(Namespaces.DATE, 'GetDaysInMonth'))!.execute(fep))
|
|
34
|
+
.allResults()[0]
|
|
35
|
+
.getResult()
|
|
36
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
37
|
+
expect(result).toBe(31);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('should return the days in year using GetDaysInYear', async () => {
|
|
41
|
+
const fep = new FunctionExecutionParameters(
|
|
42
|
+
new KIRunFunctionRepository(),
|
|
43
|
+
new KIRunSchemaRepository(),
|
|
44
|
+
).setArguments(new Map([[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2024-01-01']]));
|
|
45
|
+
|
|
46
|
+
const result = (await (await repo.find(Namespaces.DATE, 'GetDaysInYear'))!.execute(fep))
|
|
47
|
+
.allResults()[0]
|
|
48
|
+
.getResult()
|
|
49
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
50
|
+
expect(result).toBe(366);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('should return the day of week using GetDayOfWeek', async () => {
|
|
54
|
+
const fep = new FunctionExecutionParameters(
|
|
55
|
+
new KIRunFunctionRepository(),
|
|
56
|
+
new KIRunSchemaRepository(),
|
|
57
|
+
).setArguments(new Map([[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2024-01-01']]));
|
|
58
|
+
|
|
59
|
+
const result = (await (await repo.find(Namespaces.DATE, 'GetDayOfWeek'))!.execute(fep))
|
|
60
|
+
.allResults()[0]
|
|
61
|
+
.getResult()
|
|
62
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
63
|
+
expect(result).toBe(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('should return the days in a non leap year using GetDaysInYear', async () => {
|
|
67
|
+
const fep = new FunctionExecutionParameters(
|
|
68
|
+
new KIRunFunctionRepository(),
|
|
69
|
+
new KIRunSchemaRepository(),
|
|
70
|
+
).setArguments(new Map([[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2023-01-01']]));
|
|
71
|
+
|
|
72
|
+
const result = (await (await repo.find(Namespaces.DATE, 'GetDaysInYear'))!.execute(fep))
|
|
73
|
+
.allResults()[0]
|
|
74
|
+
.getResult()
|
|
75
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
76
|
+
expect(result).toBe(365);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('should return the date with the day set using SetDay', async () => {
|
|
80
|
+
const fep = new FunctionExecutionParameters(
|
|
81
|
+
new KIRunFunctionRepository(),
|
|
82
|
+
new KIRunSchemaRepository(),
|
|
83
|
+
).setArguments(
|
|
84
|
+
new Map<string, any>([
|
|
85
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME, '2024-01-01'],
|
|
86
|
+
[AbstractDateFunction.PARAMETER_NUMBER_NAME, 2],
|
|
87
|
+
]),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const result = (await (await repo.find(Namespaces.DATE, 'SetDay'))!.execute(fep))
|
|
91
|
+
.allResults()[0]
|
|
92
|
+
.getResult()
|
|
93
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
94
|
+
expect(result).toBe('2024-01-02T00:00:00.000+05:30');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Settings } from 'luxon';
|
|
2
|
+
import { KIRunSchemaRepository, Namespaces } from '../../../../../src';
|
|
3
|
+
import { FunctionExecutionParameters } from '../../../../../src';
|
|
4
|
+
import { KIRunFunctionRepository } from '../../../../../src';
|
|
5
|
+
import { AbstractDateFunction } from '../../../../../src/engine/function/system/date/AbstractDateFunction';
|
|
6
|
+
import { DateFunctionRepository } from '../../../../../src/engine/function/system/date/DateFunctionRepository';
|
|
7
|
+
|
|
8
|
+
Settings.defaultZone = 'Asia/Kolkata';
|
|
9
|
+
|
|
10
|
+
describe('Difference of dates', () => {
|
|
11
|
+
test('should return the difference in default', async () => {
|
|
12
|
+
const fep = new FunctionExecutionParameters(
|
|
13
|
+
new KIRunFunctionRepository(),
|
|
14
|
+
new KIRunSchemaRepository(),
|
|
15
|
+
).setArguments(
|
|
16
|
+
new Map<string, any>([
|
|
17
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_ONE, '2025-01-01'],
|
|
18
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_TWO, '2024-04-25'],
|
|
19
|
+
]),
|
|
20
|
+
);
|
|
21
|
+
const result = await (await new DateFunctionRepository().find(
|
|
22
|
+
Namespaces.DATE,
|
|
23
|
+
'Difference',
|
|
24
|
+
))!.execute(fep);
|
|
25
|
+
expect(
|
|
26
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME),
|
|
27
|
+
).toMatchObject({ milliseconds: 21686400000 });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('should return the difference in days', async () => {
|
|
31
|
+
const fep = new FunctionExecutionParameters(
|
|
32
|
+
new KIRunFunctionRepository(),
|
|
33
|
+
new KIRunSchemaRepository(),
|
|
34
|
+
).setArguments(
|
|
35
|
+
new Map<string, any>([
|
|
36
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_ONE, '2025-01-01T10:20:30+05:30'],
|
|
37
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_TWO, '2024-04-25T10:20:30-05:00'],
|
|
38
|
+
[AbstractDateFunction.PARAMETER_UNIT_NAME, ['DAYS']],
|
|
39
|
+
]),
|
|
40
|
+
);
|
|
41
|
+
const result = await (await new DateFunctionRepository().find(
|
|
42
|
+
Namespaces.DATE,
|
|
43
|
+
'Difference',
|
|
44
|
+
))!.execute(fep);
|
|
45
|
+
expect(
|
|
46
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME),
|
|
47
|
+
).toMatchObject({ days: 250.5625 });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('should return the difference in months,days,hours,minutes', async () => {
|
|
51
|
+
const fep = new FunctionExecutionParameters(
|
|
52
|
+
new KIRunFunctionRepository(),
|
|
53
|
+
new KIRunSchemaRepository(),
|
|
54
|
+
).setArguments(
|
|
55
|
+
new Map<string, any>([
|
|
56
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_ONE, '2025-01-01T10:20:30+05:30'],
|
|
57
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_TWO, '2024-04-25T10:20:30-05:00'],
|
|
58
|
+
[AbstractDateFunction.PARAMETER_UNIT_NAME, ['MONTHS', 'DAYS', 'HOURS', 'MINUTES']],
|
|
59
|
+
]),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const result = await (await new DateFunctionRepository().find(
|
|
63
|
+
Namespaces.DATE,
|
|
64
|
+
'Difference',
|
|
65
|
+
))!.execute(fep);
|
|
66
|
+
|
|
67
|
+
expect(
|
|
68
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME),
|
|
69
|
+
).toMatchObject({ months: 8, days: 6, hours: 13, minutes: 30 });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('should return the difference in negative months,days,hours,minutes', async () => {
|
|
73
|
+
const fep = new FunctionExecutionParameters(
|
|
74
|
+
new KIRunFunctionRepository(),
|
|
75
|
+
new KIRunSchemaRepository(),
|
|
76
|
+
).setArguments(
|
|
77
|
+
new Map<string, any>([
|
|
78
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_ONE, '2024-01-01T10:20:30+05:30'],
|
|
79
|
+
[AbstractDateFunction.PARAMETER_TIMESTAMP_NAME_TWO, '2025-04-25T10:20:30-05:00'],
|
|
80
|
+
[AbstractDateFunction.PARAMETER_UNIT_NAME, ['MONTHS', 'DAYS', 'HOURS', 'MINUTES']],
|
|
81
|
+
]),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const result = await (await new DateFunctionRepository().find(
|
|
85
|
+
Namespaces.DATE,
|
|
86
|
+
'Difference',
|
|
87
|
+
))!.execute(fep);
|
|
88
|
+
|
|
89
|
+
expect(
|
|
90
|
+
result.allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME),
|
|
91
|
+
).toMatchObject({ months: -15, days: -24, hours: -10, minutes: -30 });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
2
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository, Namespaces } from '../../../../../src';
|
|
3
|
+
import { DateFunctionRepository } from '../../../../../src/engine/function/system/date/DateFunctionRepository';
|
|
4
|
+
import { Settings } from 'luxon';
|
|
5
|
+
|
|
6
|
+
Settings.defaultZone = 'Asia/Kolkata';
|
|
7
|
+
|
|
8
|
+
describe('testing EpochToDateFunction', () => {
|
|
9
|
+
test('Epoch To Date', async () => {
|
|
10
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
11
|
+
new KIRunFunctionRepository(),
|
|
12
|
+
new KIRunSchemaRepository(),
|
|
13
|
+
).setArguments(new Map([['epochSeconds', 1694072117]]));
|
|
14
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
15
|
+
Namespaces.DATE,
|
|
16
|
+
'EpochSecondsToTimestamp',
|
|
17
|
+
);
|
|
18
|
+
expect(
|
|
19
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
20
|
+
).toBe('2023-09-07T07:35:17.000Z');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Epoch To Date 2', async () => {
|
|
24
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
25
|
+
new KIRunFunctionRepository(),
|
|
26
|
+
new KIRunSchemaRepository(),
|
|
27
|
+
).setArguments(new Map([['epochMilliseconds', 1694072117000]]));
|
|
28
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
29
|
+
Namespaces.DATE,
|
|
30
|
+
'EpochMillisecondsToTimestamp',
|
|
31
|
+
);
|
|
32
|
+
expect(
|
|
33
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
34
|
+
).toBe('2023-09-07T07:35:17.000Z');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Epoch To Date 3', async () => {
|
|
38
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
39
|
+
new KIRunFunctionRepository(),
|
|
40
|
+
new KIRunSchemaRepository(),
|
|
41
|
+
).setArguments(new Map([['epochSeconds', 169407211700]]));
|
|
42
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
43
|
+
Namespaces.DATE,
|
|
44
|
+
'EpochSecondsToTimestamp',
|
|
45
|
+
);
|
|
46
|
+
expect(
|
|
47
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
48
|
+
).toBe('7338-04-20T14:48:20.000Z');
|
|
49
|
+
});
|
|
50
|
+
test('epoch string to date 1', async () => {
|
|
51
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
52
|
+
new KIRunFunctionRepository(),
|
|
53
|
+
new KIRunSchemaRepository(),
|
|
54
|
+
).setArguments(new Map([['epochSeconds', '1696489387']]));
|
|
55
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
56
|
+
Namespaces.DATE,
|
|
57
|
+
'EpochSecondsToTimestamp',
|
|
58
|
+
);
|
|
59
|
+
expect(
|
|
60
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
61
|
+
).toBe('2023-10-05T07:03:07.000Z');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('epoch string to date 2', async () => {
|
|
65
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
66
|
+
new KIRunFunctionRepository(),
|
|
67
|
+
new KIRunSchemaRepository(),
|
|
68
|
+
).setArguments(new Map([['epochSeconds', '1696489387']]));
|
|
69
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
70
|
+
Namespaces.DATE,
|
|
71
|
+
'EpochSecondsToTimestamp',
|
|
72
|
+
);
|
|
73
|
+
expect(
|
|
74
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
75
|
+
).toBe('2023-10-05T07:03:07.000Z');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('epoch string to date 3', async () => {
|
|
79
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
80
|
+
new KIRunFunctionRepository(),
|
|
81
|
+
new KIRunSchemaRepository(),
|
|
82
|
+
).setArguments(new Map([['epochMilliseconds', '1696489386']]));
|
|
83
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
84
|
+
Namespaces.DATE,
|
|
85
|
+
'EpochMillisecondsToTimestamp',
|
|
86
|
+
);
|
|
87
|
+
expect(
|
|
88
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
89
|
+
).toBe('1970-01-20T15:14:49.386Z');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('epoch string to date 4 all chars', async () => {
|
|
93
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
94
|
+
new KIRunFunctionRepository(),
|
|
95
|
+
new KIRunSchemaRepository(),
|
|
96
|
+
).setArguments(new Map([['epochSeconds', 'abcdef']]));
|
|
97
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
98
|
+
Namespaces.DATE,
|
|
99
|
+
'EpochSecondsToTimestamp',
|
|
100
|
+
);
|
|
101
|
+
expect(async () =>
|
|
102
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
103
|
+
).rejects.toThrow('Please provide a valid value for epochSeconds.');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('epoch test for large string function', async () => {
|
|
107
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
108
|
+
new KIRunFunctionRepository(),
|
|
109
|
+
new KIRunSchemaRepository(),
|
|
110
|
+
).setArguments(new Map([['epochSeconds', '1696494131']]));
|
|
111
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
112
|
+
Namespaces.DATE,
|
|
113
|
+
'EpochSecondsToTimestamp',
|
|
114
|
+
);
|
|
115
|
+
expect(
|
|
116
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
117
|
+
).toBe('2023-10-05T08:22:11.000Z');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('epoch test for small string function', async () => {
|
|
121
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
122
|
+
new KIRunFunctionRepository(),
|
|
123
|
+
new KIRunSchemaRepository(),
|
|
124
|
+
).setArguments(new Map([['epochSeconds', '169640']]));
|
|
125
|
+
const epochToDate = await new DateFunctionRepository().find(
|
|
126
|
+
Namespaces.DATE,
|
|
127
|
+
'EpochSecondsToTimestamp',
|
|
128
|
+
);
|
|
129
|
+
expect(
|
|
130
|
+
(await epochToDate!.execute(fep)).allResults()[0].getResult().get('isoTimeStamp'),
|
|
131
|
+
).toBe('1970-01-02T23:07:20.000Z');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FromDateString } from '../../../../../src/engine/function/system/date/FromDateString';
|
|
2
|
+
import { KIRunFunctionRepository } from '../../../../../src/engine/repository/KIRunFunctionRepository';
|
|
3
|
+
import { KIRunSchemaRepository } from '../../../../../src/engine/repository/KIRunSchemaRepository';
|
|
4
|
+
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
5
|
+
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
6
|
+
|
|
7
|
+
const fromDateString = new FromDateString();
|
|
8
|
+
|
|
9
|
+
describe('FromDateString', () => {
|
|
10
|
+
test('should return the timestamp', async () => {
|
|
11
|
+
const fep = new FunctionExecutionParameters(
|
|
12
|
+
new KIRunFunctionRepository(),
|
|
13
|
+
new KIRunSchemaRepository(),
|
|
14
|
+
).setArguments(
|
|
15
|
+
MapUtil.of(
|
|
16
|
+
FromDateString.PARAMETER_TIMESTAMP_STRING_NAME,
|
|
17
|
+
'2024-01-01',
|
|
18
|
+
FromDateString.PARAMETER_FORMAT_NAME,
|
|
19
|
+
'yyyy-MM-dd',
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const result = (await fromDateString.execute(fep))
|
|
24
|
+
.allResults()[0]
|
|
25
|
+
.getResult()
|
|
26
|
+
.get(FromDateString.EVENT_RESULT_NAME);
|
|
27
|
+
|
|
28
|
+
expect(result).toEqual('2024-01-01T00:00:00.000+05:30');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('should return the timestamp with the format', async () => {
|
|
32
|
+
const fep = new FunctionExecutionParameters(
|
|
33
|
+
new KIRunFunctionRepository(),
|
|
34
|
+
new KIRunSchemaRepository(),
|
|
35
|
+
).setArguments(
|
|
36
|
+
MapUtil.of(
|
|
37
|
+
FromDateString.PARAMETER_TIMESTAMP_STRING_NAME,
|
|
38
|
+
'2024-05',
|
|
39
|
+
FromDateString.PARAMETER_FORMAT_NAME,
|
|
40
|
+
'yyyy-MM',
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const result = (await fromDateString.execute(fep))
|
|
45
|
+
.allResults()[0]
|
|
46
|
+
.getResult()
|
|
47
|
+
.get(FromDateString.EVENT_RESULT_NAME);
|
|
48
|
+
|
|
49
|
+
expect(result).toEqual('2024-05-01T00:00:00.000+05:30');
|
|
50
|
+
});
|
|
51
|
+
});
|