@fincity/kirun-js 1.9.0 → 2.0.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.
Files changed (56) hide show
  1. package/__tests__/engine/function/system/math/MathFunctionRepositoryTest.ts +118 -75
  2. package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +3 -3
  3. package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +2 -2
  4. package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +8 -8
  5. package/__tests__/engine/json/schema/SchemaUtil.ts +1 -1
  6. package/__tests__/engine/json/schema/type/TypeUtilTest.ts +1 -1
  7. package/__tests__/engine/json/schema/validator/AnyOfAllOfOneOfValidatorTest.ts +24 -19
  8. package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +22 -22
  9. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +10 -10
  10. package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +22 -22
  11. package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +13 -13
  12. package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +10 -9
  13. package/__tests__/engine/json/schema/validator/NullValidatorTest.ts +13 -0
  14. package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +4 -4
  15. package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +32 -28
  16. package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +184 -182
  17. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +43 -32
  18. package/__tests__/engine/json/schema/validator/StringFormatSchemaValidatorTest.ts +24 -24
  19. package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +14 -14
  20. package/__tests__/engine/repository/KIRunFunctionRepositoryTest.ts +7 -7
  21. package/__tests__/engine/repository/RepositoryFilterTest.ts +7 -7
  22. package/__tests__/engine/runtime/KIRuntimeDependencyTest.ts +60 -7
  23. package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +11 -7
  24. package/__tests__/engine/runtime/KIRuntimeNoParamMapTest.ts +2 -2
  25. package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +2 -2
  26. package/__tests__/engine/runtime/KIRuntimeTest.ts +8 -6
  27. package/__tests__/engine/runtime/KIRuntimeTestWithoutGenEvent.ts +4 -1
  28. package/__tests__/engine/runtime/KIRuntimeUndefinedParamTest.ts +4 -4
  29. package/__tests__/engine/runtime/KIRuntimeValuesEmptyTest.ts +6 -6
  30. package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +35 -0
  31. package/__tests__/indexTest.ts +10 -10
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/module.js +1 -1
  35. package/dist/module.js.map +1 -1
  36. package/dist/types.d.ts +17 -17
  37. package/dist/types.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/engine/HybridRepository.ts +5 -5
  40. package/src/engine/Repository.ts +2 -2
  41. package/src/engine/function/AbstractFunction.ts +35 -31
  42. package/src/engine/function/system/array/ArrayFunctionRepository.ts +8 -6
  43. package/src/engine/function/system/math/MathFunctionRepository.ts +7 -5
  44. package/src/engine/function/system/object/ObjectFunctionRepository.ts +7 -5
  45. package/src/engine/function/system/string/StringFunctionRepository.ts +8 -6
  46. package/src/engine/json/schema/SchemaUtil.ts +33 -30
  47. package/src/engine/json/schema/validator/ArrayValidator.ts +25 -20
  48. package/src/engine/json/schema/validator/NullValidator.ts +6 -7
  49. package/src/engine/json/schema/validator/ObjectValidator.ts +32 -14
  50. package/src/engine/json/schema/validator/SchemaValidator.ts +15 -11
  51. package/src/engine/json/schema/validator/TypeValidator.ts +5 -5
  52. package/src/engine/model/Statement.ts +13 -3
  53. package/src/engine/repository/KIRunFunctionRepository.ts +3 -2
  54. package/src/engine/repository/KIRunSchemaRepository.ts +7 -5
  55. package/src/engine/runtime/KIRuntime.ts +25 -20
  56. package/src/engine/util/duplicate.ts +1 -1
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  const repo = new KIRunSchemaRepository();
11
11
 
12
- test('schema array validator test for single', () => {
12
+ test('schema array validator test for single', async () => {
13
13
  let ast = new ArraySchemaType();
14
14
  ast.setSingleSchema(Schema.ofInteger('ast'));
15
15
 
@@ -17,10 +17,10 @@ test('schema array validator test for single', () => {
17
17
 
18
18
  let arr = [12, 23, 54, 45];
19
19
 
20
- expect(ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
20
+ expect(await ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
21
21
  });
22
22
 
23
- test('schema array validator test for tuple', () => {
23
+ test('schema array validator test for tuple', async () => {
24
24
  let tupleS: Schema[] = [
25
25
  Schema.ofInteger('item1'),
26
26
  Schema.ofString('item2'),
@@ -34,10 +34,10 @@ test('schema array validator test for tuple', () => {
34
34
 
35
35
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }];
36
36
 
37
- expect(ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
37
+ expect(await ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
38
38
  });
39
39
 
40
- test('schema array validator test for single', () => {
40
+ test('schema array validator test for single', async () => {
41
41
  let ast = new ArraySchemaType();
42
42
  ast.setSingleSchema(Schema.ofInteger('ast'));
43
43
 
@@ -47,10 +47,10 @@ test('schema array validator test for single', () => {
47
47
 
48
48
  let arr = [12, 23, 54, 45];
49
49
 
50
- expect(ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
50
+ expect(await ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
51
51
  });
52
52
 
53
- test('schema array validator test for tuple', () => {
53
+ test('schema array validator test for tuple', async () => {
54
54
  let tupleS: Schema[] = [
55
55
  Schema.ofInteger('item1'),
56
56
  Schema.ofString('item2'),
@@ -66,10 +66,10 @@ test('schema array validator test for tuple', () => {
66
66
 
67
67
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }, 1, 2, 4];
68
68
 
69
- expect(ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
69
+ expect(await ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
70
70
  });
71
71
 
72
- test('schema array validator test for tuple with add schema', () => {
72
+ test('schema array validator test for tuple with add schema', async () => {
73
73
  let tupleS: Schema[] = [
74
74
  Schema.ofInteger('item1'),
75
75
  Schema.ofString('item2'),
@@ -85,10 +85,10 @@ test('schema array validator test for tuple with add schema', () => {
85
85
 
86
86
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }, 1, 2];
87
87
 
88
- expect(ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
88
+ expect(await ArrayValidator.validate([], schema, repo, arr)).toStrictEqual(arr);
89
89
  });
90
90
 
91
- test('schema array validator test for tuple with add schema fail', () => {
91
+ test('schema array validator test for tuple with add schema fail', async () => {
92
92
  let tupleS: Schema[] = [
93
93
  Schema.ofInteger('item1'),
94
94
  Schema.ofString('item2'),
@@ -104,10 +104,10 @@ test('schema array validator test for tuple with add schema fail', () => {
104
104
 
105
105
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }, 1, 2, 4, 'surendhar'];
106
106
 
107
- expect(() => ArrayValidator.validate([], schema, repo, arr)).toThrow();
107
+ expect(ArrayValidator.validate([], schema, repo, arr)).rejects.toThrow();
108
108
  });
109
109
 
110
- test('schema array validator test for tuple with add schema fail', () => {
110
+ test('schema array validator test for tuple with add schema fail', async () => {
111
111
  let tupleS: Schema[] = [Schema.ofInteger('item1'), Schema.ofString('item2')];
112
112
 
113
113
  let ast = new ArraySchemaType();
@@ -119,10 +119,10 @@ test('schema array validator test for tuple with add schema fail', () => {
119
119
 
120
120
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }, 1, 2, 4, ['ve', 23, 'ctor']];
121
121
 
122
- expect(() => ArrayValidator.validate([], schema, repo, arr)).toThrow();
122
+ expect(ArrayValidator.validate([], schema, repo, arr)).rejects.toThrow();
123
123
  });
124
124
 
125
- test('schema array validator test for single with additional', () => {
125
+ test('schema array validator test for single with additional', async () => {
126
126
  let ast = new ArraySchemaType();
127
127
  ast.setSingleSchema(Schema.ofInteger('ast'));
128
128
 
@@ -132,10 +132,10 @@ test('schema array validator test for single with additional', () => {
132
132
 
133
133
  let arr = [12, 23, 54, 45, 'abcd', 'df'];
134
134
 
135
- expect(() => ArrayValidator.validate([], schema, repo, arr)).toThrow();
135
+ expect(ArrayValidator.validate([], schema, repo, arr)).rejects.toThrow();
136
136
  });
137
137
 
138
- test('schema array validator test for tuple without additional', () => {
138
+ test('schema array validator test for tuple without additional', async () => {
139
139
  let tupleS: Schema[] = [
140
140
  Schema.ofInteger('item1'),
141
141
  Schema.ofString('item2'),
@@ -149,10 +149,10 @@ test('schema array validator test for tuple without additional', () => {
149
149
 
150
150
  let arr = [12, 'surendhar', { a: 'val1', b: 'val2' }, 'add'];
151
151
 
152
- expect(() => ArrayValidator.validate([], schema, repo, arr)).toThrow();
152
+ expect(ArrayValidator.validate([], schema, repo, arr)).rejects.toThrow();
153
153
  });
154
154
 
155
- test('schema array validator tuple schema with json object', () => {
155
+ test('schema array validator tuple schema with json object', async () => {
156
156
  let tupleS: Schema[] = [
157
157
  Schema.ofInteger('item1'),
158
158
  Schema.ofString('item2'),
@@ -166,10 +166,10 @@ test('schema array validator tuple schema with json object', () => {
166
166
 
167
167
  let obj = [1, 'asd', { val: 'stringtype' }, 'stringOnemore'];
168
168
 
169
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
169
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
170
170
  });
171
171
 
172
- test('schema array validator tuple schema similar to json object', () => {
172
+ test('schema array validator tuple schema similar to json object', async () => {
173
173
  let tupleS: Schema[] = [
174
174
  Schema.ofInteger('item1'),
175
175
  Schema.ofString('item2'),
@@ -187,5 +187,5 @@ test('schema array validator tuple schema similar to json object', () => {
187
187
 
188
188
  let obj = [1, 'asd', true, { val: 'stringtype' }, false];
189
189
 
190
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
190
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
191
191
  });
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  const repo = new KIRunSchemaRepository();
11
11
 
12
- test('schema array validator tuple schema test for additional items with boolean different datatype', () => {
12
+ test('schema array validator tuple schema test for additional items with boolean different datatype', async () => {
13
13
  let schema = Schema.from({
14
14
  type: 'ARRAY',
15
15
  items: [
@@ -35,10 +35,10 @@ test('schema array validator tuple schema test for additional items with boolean
35
35
 
36
36
  let obj = [1, 'asd', { val: 'stringtype' }, 'stringOnemore'];
37
37
 
38
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
38
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
39
39
  });
40
40
 
41
- test('schema array validator tuple schema test for additional items with boolean true datatype', () => {
41
+ test('schema array validator tuple schema test for additional items with boolean true datatype', async () => {
42
42
  let schema = Schema.from({
43
43
  type: 'ARRAY',
44
44
  items: [
@@ -58,10 +58,10 @@ test('schema array validator tuple schema test for additional items with boolean
58
58
 
59
59
  let obj = ['asd', true, { a: 'b' }];
60
60
 
61
- expect(SchemaValidator.validate([], schema, repo, obj)).toStrictEqual(obj);
61
+ expect(await SchemaValidator.validate([], schema, repo, obj)).toStrictEqual(obj);
62
62
  });
63
63
 
64
- test('schema array validator test for additional items with boolean false different datatype', () => {
64
+ test('schema array validator test for additional items with boolean false different datatype', async () => {
65
65
  let schema = Schema.from({
66
66
  type: 'ARRAY',
67
67
  items: { type: 'INTEGER' },
@@ -69,10 +69,10 @@ test('schema array validator test for additional items with boolean false differ
69
69
  });
70
70
  let obj = [1, 2, 3, 4, 'stringtype', true];
71
71
 
72
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
72
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
73
73
  });
74
74
 
75
- test('schema array validator test for additional items with boolean true different datatype', () => {
75
+ test('schema array validator test for additional items with boolean true different datatype', async () => {
76
76
  let schema = Schema.from({
77
77
  type: 'ARRAY',
78
78
  items: {
@@ -87,10 +87,10 @@ test('schema array validator test for additional items with boolean true differe
87
87
 
88
88
  let obj = [1, 2, 3, 'stringtype', true];
89
89
 
90
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
90
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
91
91
  });
92
92
 
93
- test('schema array validator tuple schema test for additional items with boolean different datatype', () => {
93
+ test('schema array validator tuple schema test for additional items with boolean different datatype', async () => {
94
94
  let schema = Schema.from({
95
95
  type: 'ARRAY',
96
96
  items: [
@@ -113,10 +113,10 @@ test('schema array validator tuple schema test for additional items with boolean
113
113
 
114
114
  let obj = [1, 'asd', { val: 'stringtype' }, 'stringOnemore'];
115
115
 
116
- expect(() => SchemaValidator.validate([], schema, repo, obj)).toThrowError();
116
+ expect(SchemaValidator.validate([], schema, repo, obj)).rejects.toThrowError();
117
117
  });
118
118
 
119
- test('multi level validation inner object pollution test', () => {
119
+ test('multi level validation inner object pollution test', async () => {
120
120
  let schema = Schema.from({
121
121
  type: 'ARRAY',
122
122
  items: {
@@ -140,11 +140,11 @@ test('multi level validation inner object pollution test', () => {
140
140
  },
141
141
  });
142
142
 
143
- let value = SchemaValidator.validate(
143
+ let value = await SchemaValidator.validate(
144
144
  undefined,
145
145
  xschema,
146
146
  repo,
147
- SchemaValidator.validate(undefined, schema, repo, undefined),
147
+ await SchemaValidator.validate(undefined, schema, repo, undefined),
148
148
  );
149
149
 
150
150
  expect(schema?.getDefaultValue()[0].y).toBeUndefined();
@@ -10,9 +10,10 @@ test('NotValidation', async () => {
10
10
  SchemaType.STRING,
11
11
  )
12
12
  .setDefaultValue(1)
13
- .setNot(Schema.of('Not Schema', SchemaType.STRING));
13
+ .setNot(Schema.of('Not String', SchemaType.STRING));
14
14
 
15
- const value = SchemaValidator.validate(undefined, sch, undefined, 0);
15
+ const value = await SchemaValidator.validate(undefined, sch, undefined, 0);
16
+ console.log(value);
16
17
  expect(value).toBe(0);
17
18
 
18
19
  sch = Schema.of(
@@ -24,24 +25,24 @@ test('NotValidation', async () => {
24
25
  SchemaType.STRING,
25
26
  )
26
27
  .setDefaultValue(1)
27
- .setNot(Schema.of('Not Schema', SchemaType.INTEGER));
28
+ .setNot(Schema.of('Not Integer', SchemaType.INTEGER));
28
29
 
29
- expect(() => SchemaValidator.validate(undefined, sch, undefined, 0)).toThrow();
30
+ expect(SchemaValidator.validate(undefined, sch, undefined, 0)).rejects.toThrow();
30
31
 
31
32
  sch = Schema.of('Not Schema', SchemaType.INTEGER, SchemaType.LONG, SchemaType.FLOAT)
32
33
  .setDefaultValue(1)
33
34
  .setNot(new Schema().setConstant(0));
34
35
 
35
- expect(() => SchemaValidator.validate(undefined, sch, undefined, 0)).toThrow();
36
- expect(SchemaValidator.validate(undefined, sch, undefined, null)).toBe(1);
37
- expect(SchemaValidator.validate(undefined, sch, undefined, 2)).toBe(2);
36
+ expect(SchemaValidator.validate(undefined, sch, undefined, 0)).rejects.toThrow();
37
+ expect(await SchemaValidator.validate(undefined, sch, undefined, null)).toBe(1);
38
+ expect(await SchemaValidator.validate(undefined, sch, undefined, 2)).toBe(2);
38
39
  });
39
40
 
40
41
  test('constantValidation', async () => {
41
42
  let sch = Schema.of('Constant Schema', SchemaType.INTEGER).setConstant(1);
42
43
 
43
- const value = SchemaValidator.validate(undefined, sch, undefined, 1);
44
+ const value = await SchemaValidator.validate(undefined, sch, undefined, 1);
44
45
  expect(value).toBe(1);
45
46
 
46
- expect(() => SchemaValidator.validate(undefined, sch, undefined, 0)).toThrow();
47
+ expect(SchemaValidator.validate(undefined, sch, undefined, 0)).rejects.toThrow();
47
48
  });
@@ -0,0 +1,13 @@
1
+ import { Schema, SchemaValidator } from '../../../../../src';
2
+
3
+ test('Check for valid Null value', async () => {
4
+ let schema = Schema.from({
5
+ type: 'NULL',
6
+ });
7
+
8
+ expect(async () => SchemaValidator.validate([], schema!, undefined, 23)).rejects.toThrowError();
9
+ expect(async () => SchemaValidator.validate([], schema!, undefined, 0)).rejects.toThrowError();
10
+ expect(async () => SchemaValidator.validate([], schema!, undefined, '')).rejects.toThrowError();
11
+ expect(await SchemaValidator.validate([], schema!, undefined, null)).toBeNull();
12
+ expect(await SchemaValidator.validate([], schema!, undefined, undefined)).toBeUndefined();
13
+ });
@@ -2,7 +2,7 @@ import { KIRunSchemaRepository, Schema, SchemaType, SchemaValidator } from '../.
2
2
 
3
3
  const repo = new KIRunSchemaRepository();
4
4
 
5
- test('schema Object validator test schema based old ARRAY style', () => {
5
+ test('schema Object validator test schema based old ARRAY style', async () => {
6
6
  let schema = Schema.from({
7
7
  type: 'OBJECT',
8
8
  properties: { name: { type: 'STRING' } },
@@ -11,13 +11,13 @@ test('schema Object validator test schema based old ARRAY style', () => {
11
11
  expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
12
12
 
13
13
  var obj = { name: 'Kiran', num: [1, 2, 3] };
14
- expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
14
+ expect(await SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
15
15
 
16
- expect(() =>
16
+ expect(
17
17
  SchemaValidator.validate([], schema!, repo, {
18
18
  name: 'Kiran',
19
19
  num: 23,
20
20
  lastName: 'grandhi',
21
21
  }),
22
- ).toThrowError();
22
+ ).rejects.toThrowError();
23
23
  });
@@ -10,7 +10,7 @@ import {
10
10
 
11
11
  const repo = new KIRunSchemaRepository();
12
12
 
13
- test('schema Object validator test boolean value', () => {
13
+ test('schema Object validator test boolean value', async () => {
14
14
  let schema = Schema.from({
15
15
  type: 'OBJECT',
16
16
  properties: { name: { type: 'STRING' } },
@@ -18,16 +18,16 @@ test('schema Object validator test boolean value', () => {
18
18
  });
19
19
  expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
20
20
 
21
- expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
21
+ expect(await SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
22
22
  name: 'Kiran',
23
23
  });
24
24
 
25
- expect(() =>
25
+ expect(
26
26
  SchemaValidator.validate([], schema!, repo, { name: 'Kiran', lastName: 'Grandhi' }),
27
- ).toThrowError();
27
+ ).rejects.toThrowError();
28
28
  });
29
29
 
30
- test('schema Object validator test schema based', () => {
30
+ test('schema Object validator test schema based', async () => {
31
31
  let schema = Schema.from({
32
32
  type: 'OBJECT',
33
33
  properties: { name: { type: 'STRING' } },
@@ -35,37 +35,39 @@ test('schema Object validator test schema based', () => {
35
35
  });
36
36
  expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
37
37
 
38
- expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 })).toStrictEqual({
38
+ expect(
39
+ await SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 }),
40
+ ).toStrictEqual({
39
41
  name: 'Kiran',
40
42
  num: 23,
41
43
  });
42
44
 
43
- expect(() =>
45
+ expect(
44
46
  SchemaValidator.validate([], schema!, repo, {
45
47
  name: 'Kiran',
46
48
  num: 23,
47
49
  lastName: 'grandhi',
48
50
  }),
49
- ).toThrowError();
51
+ ).rejects.toThrowError();
50
52
  });
51
53
 
52
- test('schema Object validator test boolean value old style', () => {
54
+ test('schema Object validator test boolean value old style', async () => {
53
55
  let schema = Schema.from({
54
56
  type: 'OBJECT',
55
57
  properties: { name: { type: 'STRING' } },
56
58
  additionalProperties: { booleanValue: false },
57
59
  });
58
60
 
59
- expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
61
+ expect(await SchemaValidator.validate([], schema!, repo, { name: 'Kiran' })).toStrictEqual({
60
62
  name: 'Kiran',
61
63
  });
62
64
 
63
- expect(() =>
65
+ expect(
64
66
  SchemaValidator.validate([], schema!, repo, { name: 'Kiran', lastName: 'Grandhi' }),
65
- ).toThrowError();
67
+ ).rejects.toThrowError();
66
68
  });
67
69
 
68
- test('schema Object validator test schema based old style', () => {
70
+ test('schema Object validator test schema based old style', async () => {
69
71
  let schema = Schema.from({
70
72
  type: 'OBJECT',
71
73
  properties: { name: { type: 'STRING' } },
@@ -73,21 +75,23 @@ test('schema Object validator test schema based old style', () => {
73
75
  });
74
76
  expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
75
77
 
76
- expect(SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 })).toStrictEqual({
78
+ expect(
79
+ await SchemaValidator.validate([], schema!, repo, { name: 'Kiran', num: 23 }),
80
+ ).toStrictEqual({
77
81
  name: 'Kiran',
78
82
  num: 23,
79
83
  });
80
84
 
81
- expect(() =>
85
+ expect(
82
86
  SchemaValidator.validate([], schema!, repo, {
83
87
  name: 'Kiran',
84
88
  num: 23,
85
89
  lastName: 'grandhi',
86
90
  }),
87
- ).toThrowError();
91
+ ).rejects.toThrowError();
88
92
  });
89
93
 
90
- test('schema Object validator test schema based old ARRAY style', () => {
94
+ test('schema Object validator test schema based old ARRAY style', async () => {
91
95
  let schema = Schema.from({
92
96
  type: 'OBJECT',
93
97
  properties: { name: { type: 'STRING' } },
@@ -96,18 +100,18 @@ test('schema Object validator test schema based old ARRAY style', () => {
96
100
  expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
97
101
 
98
102
  var obj = { name: 'Kiran', num: [1, 2, 3] };
99
- expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
103
+ expect(await SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
100
104
 
101
- expect(() =>
105
+ expect(
102
106
  SchemaValidator.validate([], schema!, repo, {
103
107
  name: 'Kiran',
104
108
  num: 23,
105
109
  lastName: 'grandhi',
106
110
  }),
107
- ).toThrowError();
111
+ ).rejects.toThrowError();
108
112
  });
109
113
 
110
- test('schema Object validator test schema based old Object style', () => {
114
+ test('schema Object validator test schema based old Object style', async () => {
111
115
  let schema = Schema.from({
112
116
  type: 'OBJECT',
113
117
  properties: {
@@ -119,7 +123,7 @@ test('schema Object validator test schema based old Object style', () => {
119
123
  });
120
124
 
121
125
  var obj = { name: 'Kiran', age: 23 };
122
- expect(SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
126
+ expect(await SchemaValidator.validate([], schema!, repo, obj)).toStrictEqual(obj);
123
127
 
124
128
  var objwithAdditional = {
125
129
  name: 'Kiran',
@@ -130,7 +134,7 @@ test('schema Object validator test schema based old Object style', () => {
130
134
  },
131
135
  };
132
136
 
133
- expect(SchemaValidator.validate([], schema!, repo, objwithAdditional)).toStrictEqual(
137
+ expect(await SchemaValidator.validate([], schema!, repo, objwithAdditional)).toStrictEqual(
134
138
  objwithAdditional,
135
139
  );
136
140
 
@@ -144,10 +148,10 @@ test('schema Object validator test schema based old Object style', () => {
144
148
  city: 'kakinada',
145
149
  };
146
150
 
147
- expect(() => SchemaValidator.validate([], schema!, repo, objwithMoreAdditional)).toThrow();
151
+ expect(SchemaValidator.validate([], schema!, repo, objwithMoreAdditional)).rejects.toThrow();
148
152
  });
149
153
 
150
- test('Schema test with object value as null for any', () => {
154
+ test('Schema test with object value as null for any', async () => {
151
155
  let filterOperator = Schema.from({
152
156
  namespace: 'test',
153
157
  name: 'filterOperator',
@@ -260,14 +264,14 @@ test('Schema test with object value as null for any', () => {
260
264
  schemaMap.set('FilterCondition', filterCondition!);
261
265
 
262
266
  class TestRepository implements Repository<Schema> {
263
- public find(namespace: string, name: string): Schema | undefined {
267
+ public async find(namespace: string, name: string): Promise<Schema | undefined> {
264
268
  if (!namespace) {
265
269
  return undefined;
266
270
  }
267
271
  return schemaMap.get(name);
268
272
  }
269
273
 
270
- public filter(name: string): string[] {
274
+ public async filter(name: string): Promise<string[]> {
271
275
  return [];
272
276
  }
273
277
  }
@@ -275,6 +279,6 @@ test('Schema test with object value as null for any', () => {
275
279
 
276
280
  var tempOb2 = { field: 'nullcheck', operator: 'LESS_THAN', value: null, isValue: true };
277
281
 
278
- var res3 = SchemaValidator.validate(undefined, filterCondition, repo, tempOb2);
282
+ var res3 = await SchemaValidator.validate(undefined, filterCondition, repo, tempOb2);
279
283
  expect(res3).toStrictEqual(tempOb2);
280
284
  });