@fincity/kirun-js 2.0.5 → 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/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/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
|
+
});
|