@fincity/kirun-js 2.0.4 → 2.1.0
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 +59 -0
- package/__tests__/engine/function/system/array/DisjointTest.ts +1 -1
- 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/Wait.ts +37 -0
- package/src/engine/function/system/string/StringFunctionRepository.ts +1 -1
- package/src/engine/json/schema/validator/NumberValidator.ts +10 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionExecutionParameters,
|
|
3
|
+
KIRunFunctionRepository,
|
|
4
|
+
KIRunSchemaRepository,
|
|
5
|
+
} from '../../../../src';
|
|
6
|
+
import { Wait } from '../../../../src/engine/function/system/Wait';
|
|
7
|
+
|
|
8
|
+
const waitFunction = new Wait();
|
|
9
|
+
|
|
10
|
+
test('wait test', async () => {
|
|
11
|
+
const waitTime = 1000;
|
|
12
|
+
const startTime = new Date().getTime();
|
|
13
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
14
|
+
new KIRunFunctionRepository(),
|
|
15
|
+
new KIRunSchemaRepository(),
|
|
16
|
+
);
|
|
17
|
+
await waitFunction.execute(fep.setArguments(new Map([['millis', waitTime]])));
|
|
18
|
+
|
|
19
|
+
const endTime = new Date().getTime();
|
|
20
|
+
expect(endTime - startTime).toBeGreaterThanOrEqual(waitTime);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('wait test 3500ms', async () => {
|
|
24
|
+
const waitTime = 3500;
|
|
25
|
+
const startTime = new Date().getTime();
|
|
26
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
27
|
+
new KIRunFunctionRepository(),
|
|
28
|
+
new KIRunSchemaRepository(),
|
|
29
|
+
);
|
|
30
|
+
await waitFunction.execute(fep.setArguments(new Map([['millis', waitTime]])));
|
|
31
|
+
|
|
32
|
+
const endTime = new Date().getTime();
|
|
33
|
+
expect(endTime - startTime).toBeGreaterThanOrEqual(waitTime);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('wait test immediately', async () => {
|
|
37
|
+
const startTime = new Date().getTime();
|
|
38
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
39
|
+
new KIRunFunctionRepository(),
|
|
40
|
+
new KIRunSchemaRepository(),
|
|
41
|
+
);
|
|
42
|
+
await waitFunction.execute(fep.setArguments(new Map()));
|
|
43
|
+
|
|
44
|
+
const endTime = new Date().getTime();
|
|
45
|
+
expect(endTime - startTime).toBeLessThan(10);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('wait test error with negative number', async () => {
|
|
49
|
+
const waitTime = -3500;
|
|
50
|
+
|
|
51
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
52
|
+
new KIRunFunctionRepository(),
|
|
53
|
+
new KIRunSchemaRepository(),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
waitFunction.execute(fep.setArguments(new Map([['millis', waitTime]]))),
|
|
58
|
+
).rejects.toThrowError();
|
|
59
|
+
});
|
|
@@ -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
|
+
});
|