@jsonforms/core 3.0.0-beta.1 → 3.0.0-beta.4
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/README.md +11 -0
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +357 -217
- package/docs/index.html +29 -4
- package/docs/interfaces/addcellrendereraction.html +3 -3
- package/docs/interfaces/addrendereraction.html +3 -3
- package/docs/interfaces/adduischemaaction.html +3 -3
- package/docs/interfaces/andcondition.html +2 -2
- package/docs/interfaces/arraycontrolprops.html +21 -21
- package/docs/interfaces/arraylayoutprops.html +21 -21
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +12 -12
- package/docs/interfaces/combinatorrendererprops.html +143 -36
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +22 -4
- package/docs/interfaces/controlprops.html +16 -16
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +17 -17
- package/docs/interfaces/dispatchcellprops.html +10 -10
- package/docs/interfaces/dispatchcellstateprops.html +10 -10
- package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
- package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
- package/docs/interfaces/enumcellprops.html +13 -13
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initactionoptions.html +14 -0
- package/docs/interfaces/internationalizable.html +167 -0
- package/docs/interfaces/jsonformscore.html +17 -3
- package/docs/interfaces/jsonformsprops.html +9 -9
- package/docs/interfaces/labeldescription.html +2 -2
- package/docs/interfaces/labelelement.html +4 -4
- package/docs/interfaces/layout.html +4 -4
- package/docs/interfaces/layoutprops.html +10 -10
- package/docs/interfaces/leafcondition.html +2 -2
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +9 -9
- package/docs/interfaces/ownpropsofcontrol.html +9 -12
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +10 -10
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
- package/docs/interfaces/ownpropsoflayout.html +9 -9
- package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
- package/docs/interfaces/ownpropsofrenderer.html +8 -8
- package/docs/interfaces/registerdefaultdataaction.html +3 -3
- package/docs/interfaces/removecellrendereraction.html +3 -3
- package/docs/interfaces/removerendereraction.html +3 -3
- package/docs/interfaces/removeuischemaaction.html +2 -2
- package/docs/interfaces/rendererprops.html +9 -9
- package/docs/interfaces/rule.html +2 -2
- package/docs/interfaces/schemabasedcondition.html +2 -2
- package/docs/interfaces/setajvaction.html +2 -2
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +2 -2
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/settranslatoraction.html +3 -3
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +17 -17
- package/docs/interfaces/statepropsofarraylayout.html +17 -17
- package/docs/interfaces/statepropsofcell.html +11 -11
- package/docs/interfaces/statepropsofcombinator.html +147 -40
- package/docs/interfaces/statepropsofcontrol.html +18 -15
- package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
- package/docs/interfaces/statepropsofenumcell.html +12 -12
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
- package/docs/interfaces/statepropsoflayout.html +10 -10
- package/docs/interfaces/statepropsofmasteritem.html +7 -7
- package/docs/interfaces/statepropsofrenderer.html +9 -9
- package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
- package/docs/interfaces/uischemaelement.html +3 -3
- package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
- package/docs/interfaces/updatei18naction.html +4 -4
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/actions/actions.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +201 -179
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +182 -166
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/uischema.d.ts +10 -1
- package/lib/reducers/core.d.ts +1 -0
- package/lib/reducers/reducers.d.ts +2 -2
- package/lib/testers/testers.d.ts +8 -7
- package/lib/util/combinators.d.ts +0 -1
- package/lib/util/path.d.ts +10 -0
- package/lib/util/renderer.d.ts +2 -2
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/actions.ts +1 -0
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nUtil.ts +10 -7
- package/src/models/uischema.ts +14 -1
- package/src/reducers/core.ts +30 -3
- package/src/reducers/reducers.ts +12 -4
- package/src/testers/testers.ts +61 -34
- package/src/util/combinators.ts +17 -32
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +18 -6
- package/src/util/renderer.ts +20 -32
- package/src/util/resolvers.ts +57 -68
- package/src/util/util.ts +1 -1
- package/stats.html +1 -1
- package/test/generators/uischema.test.ts +18 -0
- package/test/i18n/i18nUtil.test.ts +41 -1
- package/test/reducers/core.test.ts +203 -1
- package/test/testers.test.ts +208 -120
- package/test/util/path.test.ts +37 -20
- package/test/util/renderer.test.ts +1 -1
- package/test/util/resolvers.test.ts +99 -8
package/test/testers.test.ts
CHANGED
|
@@ -45,7 +45,8 @@ import {
|
|
|
45
45
|
schemaTypeIs,
|
|
46
46
|
scopeEndIs,
|
|
47
47
|
scopeEndsWith,
|
|
48
|
-
uiTypeIs
|
|
48
|
+
uiTypeIs,
|
|
49
|
+
isOneOfEnumControl
|
|
49
50
|
} from '../src/testers';
|
|
50
51
|
import {
|
|
51
52
|
ControlElement,
|
|
@@ -74,8 +75,8 @@ test('schemaTypeIs should check type sub-schema of control', t => {
|
|
|
74
75
|
type: 'Control',
|
|
75
76
|
scope: '#/properties/foo'
|
|
76
77
|
};
|
|
77
|
-
t.true(schemaTypeIs('string')(uischema, schema));
|
|
78
|
-
t.false(schemaTypeIs('integer')(uischema, schema));
|
|
78
|
+
t.true(schemaTypeIs('string')(uischema, schema, schema));
|
|
79
|
+
t.false(schemaTypeIs('integer')(uischema, schema, schema));
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
test('schemaTypeIs should return false for non-control UI schema elements', t => {
|
|
@@ -89,7 +90,7 @@ test('schemaTypeIs should return false for non-control UI schema elements', t =>
|
|
|
89
90
|
type: 'Label',
|
|
90
91
|
text: 'some text'
|
|
91
92
|
};
|
|
92
|
-
t.false(schemaTypeIs('integer')(label, schema));
|
|
93
|
+
t.false(schemaTypeIs('integer')(label, schema, schema));
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
test('schemaTypeIs should return false for control pointing to invalid sub-schema', t => {
|
|
@@ -103,7 +104,7 @@ test('schemaTypeIs should return false for control pointing to invalid sub-schem
|
|
|
103
104
|
foo: { type: 'string' }
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
|
-
t.false(schemaTypeIs('string')(uischema, schema));
|
|
107
|
+
t.false(schemaTypeIs('string')(uischema, schema, schema));
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
test('schemaTypeIs should return true for array type', t => {
|
|
@@ -117,8 +118,8 @@ test('schemaTypeIs should return true for array type', t => {
|
|
|
117
118
|
type: 'Control',
|
|
118
119
|
scope: '#/properties/foo'
|
|
119
120
|
};
|
|
120
|
-
t.true(schemaTypeIs('string')(uischema, schema));
|
|
121
|
-
t.true(schemaTypeIs('integer')(uischema, schema));
|
|
121
|
+
t.true(schemaTypeIs('string')(uischema, schema, schema));
|
|
122
|
+
t.true(schemaTypeIs('integer')(uischema, schema, schema));
|
|
122
123
|
});
|
|
123
124
|
|
|
124
125
|
test('formatIs should check the format of a resolved sub-schema', t => {
|
|
@@ -135,7 +136,7 @@ test('formatIs should check the format of a resolved sub-schema', t => {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
t.true(formatIs('date-time')(uischema, schema));
|
|
139
|
+
t.true(formatIs('date-time')(uischema, schema, schema));
|
|
139
140
|
});
|
|
140
141
|
|
|
141
142
|
test('uiTypeIs', t => {
|
|
@@ -143,7 +144,7 @@ test('uiTypeIs', t => {
|
|
|
143
144
|
type: 'Control',
|
|
144
145
|
scope: '#/properties/bar'
|
|
145
146
|
};
|
|
146
|
-
t.true(uiTypeIs('Control')(control, undefined));
|
|
147
|
+
t.true(uiTypeIs('Control')(control, undefined, undefined));
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
test('optionIs should check for options', t => {
|
|
@@ -154,13 +155,13 @@ test('optionIs should check for options', t => {
|
|
|
154
155
|
answer: 42
|
|
155
156
|
}
|
|
156
157
|
};
|
|
157
|
-
t.true(optionIs('answer', 42)(control, undefined));
|
|
158
|
+
t.true(optionIs('answer', 42)(control, undefined, undefined));
|
|
158
159
|
});
|
|
159
160
|
|
|
160
161
|
test('optionIs should not fail if uischema is undefined or null', t => {
|
|
161
162
|
const uischema: UISchemaElement = null;
|
|
162
|
-
t.false(optionIs('answer', 42)(uischema, undefined));
|
|
163
|
-
t.false(optionIs('answer', 42)(uischema, undefined));
|
|
163
|
+
t.false(optionIs('answer', 42)(uischema, undefined, undefined));
|
|
164
|
+
t.false(optionIs('answer', 42)(uischema, undefined, undefined));
|
|
164
165
|
});
|
|
165
166
|
|
|
166
167
|
test('optionIs should return false for UI schema elements without options cell', t => {
|
|
@@ -168,7 +169,7 @@ test('optionIs should return false for UI schema elements without options cell',
|
|
|
168
169
|
type: 'Control',
|
|
169
170
|
scope: '#/properties/bar'
|
|
170
171
|
};
|
|
171
|
-
t.false(optionIs('answer', 42)(control, undefined));
|
|
172
|
+
t.false(optionIs('answer', 42)(control, undefined, undefined));
|
|
172
173
|
});
|
|
173
174
|
|
|
174
175
|
test('schemaMatches should check type sub-schema of control via predicate', t => {
|
|
@@ -183,7 +184,7 @@ test('schemaMatches should check type sub-schema of control via predicate', t =>
|
|
|
183
184
|
scope: '#/properties/foo'
|
|
184
185
|
};
|
|
185
186
|
t.true(
|
|
186
|
-
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema)
|
|
187
|
+
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, schema)
|
|
187
188
|
);
|
|
188
189
|
});
|
|
189
190
|
|
|
@@ -198,7 +199,7 @@ test('schemaMatches should check type sub-schema of control via predicate also w
|
|
|
198
199
|
scope: '#/properties/foo'
|
|
199
200
|
};
|
|
200
201
|
t.true(
|
|
201
|
-
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema)
|
|
202
|
+
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, schema)
|
|
202
203
|
);
|
|
203
204
|
});
|
|
204
205
|
|
|
@@ -213,7 +214,7 @@ test('schemaMatches should return false for non-control UI schema elements', t =
|
|
|
213
214
|
type: 'Label',
|
|
214
215
|
text: 'some text'
|
|
215
216
|
};
|
|
216
|
-
t.false(schemaMatches(() => false)(label, schema));
|
|
217
|
+
t.false(schemaMatches(() => false)(label, schema, schema));
|
|
217
218
|
});
|
|
218
219
|
|
|
219
220
|
test('schemaMatches should return false for control pointing to invalid subschema', t => {
|
|
@@ -227,7 +228,7 @@ test('schemaMatches should return false for control pointing to invalid subschem
|
|
|
227
228
|
type: 'Control',
|
|
228
229
|
scope: '#/properties/bar'
|
|
229
230
|
};
|
|
230
|
-
t.false(schemaMatches(() => false)(uischema, schema));
|
|
231
|
+
t.false(schemaMatches(() => false)(uischema, schema, schema));
|
|
231
232
|
});
|
|
232
233
|
|
|
233
234
|
test('scopeEndsWith checks whether the ref of a control ends with a certain string', t => {
|
|
@@ -235,7 +236,7 @@ test('scopeEndsWith checks whether the ref of a control ends with a certain stri
|
|
|
235
236
|
type: 'Control',
|
|
236
237
|
scope: '#/properties/bar'
|
|
237
238
|
};
|
|
238
|
-
t.true(scopeEndsWith('properties/bar')(uischema, undefined));
|
|
239
|
+
t.true(scopeEndsWith('properties/bar')(uischema, undefined, undefined));
|
|
239
240
|
});
|
|
240
241
|
|
|
241
242
|
test('scopeEndsWith should return false for non-control UI schema elements', t => {
|
|
@@ -243,7 +244,7 @@ test('scopeEndsWith should return false for non-control UI schema elements', t =
|
|
|
243
244
|
type: 'Label',
|
|
244
245
|
text: 'some text'
|
|
245
246
|
};
|
|
246
|
-
t.false(scopeEndsWith('properties/bar')(label, undefined));
|
|
247
|
+
t.false(scopeEndsWith('properties/bar')(label, undefined, undefined));
|
|
247
248
|
});
|
|
248
249
|
|
|
249
250
|
test('refEndIs checks whether the last segment a control ref equals a certain string', t => {
|
|
@@ -251,7 +252,7 @@ test('refEndIs checks whether the last segment a control ref equals a certain st
|
|
|
251
252
|
type: 'Control',
|
|
252
253
|
scope: '#/properties/bar'
|
|
253
254
|
};
|
|
254
|
-
t.true(scopeEndIs('bar')(uischema, undefined));
|
|
255
|
+
t.true(scopeEndIs('bar')(uischema, undefined, undefined));
|
|
255
256
|
});
|
|
256
257
|
|
|
257
258
|
test('refEndIs should return false for non-control UI schema elements', t => {
|
|
@@ -259,7 +260,7 @@ test('refEndIs should return false for non-control UI schema elements', t => {
|
|
|
259
260
|
type: 'Label',
|
|
260
261
|
text: 'some text'
|
|
261
262
|
};
|
|
262
|
-
t.false(scopeEndIs('bar')(label, undefined));
|
|
263
|
+
t.false(scopeEndIs('bar')(label, undefined, undefined));
|
|
263
264
|
});
|
|
264
265
|
|
|
265
266
|
test('and should allow to compose multiple testers', t => {
|
|
@@ -273,7 +274,7 @@ test('and should allow to compose multiple testers', t => {
|
|
|
273
274
|
type: 'Control',
|
|
274
275
|
scope: '#/properties/foo'
|
|
275
276
|
};
|
|
276
|
-
t.true(and(schemaTypeIs('string'), scopeEndIs('foo'))(uischema, schema));
|
|
277
|
+
t.true(and(schemaTypeIs('string'), scopeEndIs('foo'))(uischema, schema, schema));
|
|
277
278
|
});
|
|
278
279
|
|
|
279
280
|
test('or should allow to compose multiple testers', t => {
|
|
@@ -288,7 +289,7 @@ test('or should allow to compose multiple testers', t => {
|
|
|
288
289
|
scope: '#/properties/foo'
|
|
289
290
|
};
|
|
290
291
|
t.true(
|
|
291
|
-
or(schemaTypeIs('integer'), optionIs('slider', true))(uischema, schema)
|
|
292
|
+
or(schemaTypeIs('integer'), optionIs('slider', true))(uischema, schema, schema)
|
|
292
293
|
);
|
|
293
294
|
});
|
|
294
295
|
|
|
@@ -297,52 +298,68 @@ test('tester isPrimitiveArrayControl', t => {
|
|
|
297
298
|
type: 'Control',
|
|
298
299
|
scope: '#/properties/foo'
|
|
299
300
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
items: { type: 'integer' }
|
|
307
|
-
}
|
|
301
|
+
const schema = {
|
|
302
|
+
type: 'object',
|
|
303
|
+
properties: {
|
|
304
|
+
foo: {
|
|
305
|
+
type: 'array',
|
|
306
|
+
items: { type: 'integer' }
|
|
308
307
|
}
|
|
309
|
-
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
t.true(
|
|
311
|
+
isPrimitiveArrayControl(control, schema, schema),
|
|
310
312
|
`Primitive array tester was not triggered for 'integer' schema type`
|
|
311
313
|
);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
314
|
+
const schemaWithRefs = {
|
|
315
|
+
definitions: { int: { type: 'integer' } },
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
foo: {
|
|
319
|
+
type: 'array',
|
|
320
|
+
items: { $ref: '#/definitions/int' }
|
|
320
321
|
}
|
|
321
|
-
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
t.true(
|
|
325
|
+
isPrimitiveArrayControl(control, schemaWithRefs, schemaWithRefs),
|
|
326
|
+
`Primitive array tester was not triggered for 'integer' schema type with refs`
|
|
327
|
+
);
|
|
328
|
+
const objectSchema = {
|
|
329
|
+
type: 'object',
|
|
330
|
+
properties: {
|
|
331
|
+
foo: {
|
|
332
|
+
type: 'array',
|
|
333
|
+
items: { type: 'object' }
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
t.false(
|
|
338
|
+
isPrimitiveArrayControl(control, objectSchema, objectSchema),
|
|
322
339
|
`Primitive array tester was not triggered for 'object' schema type`
|
|
323
340
|
);
|
|
324
341
|
});
|
|
325
342
|
|
|
326
343
|
test('tester isObjectArrayControl', t => {
|
|
327
|
-
t.false(isObjectArrayControl({ type: 'Foo' }, null));
|
|
344
|
+
t.false(isObjectArrayControl({ type: 'Foo' }, null, null));
|
|
328
345
|
const control: ControlElement = {
|
|
329
346
|
type: 'Control',
|
|
330
347
|
scope: '#/properties/foo'
|
|
331
348
|
};
|
|
332
|
-
t.false(isObjectArrayControl(control, undefined), 'No Schema not checked!');
|
|
349
|
+
t.false(isObjectArrayControl(control, undefined, undefined), 'No Schema not checked!');
|
|
333
350
|
|
|
334
351
|
t.false(
|
|
335
352
|
isObjectArrayControl(control, {
|
|
336
353
|
type: 'object',
|
|
337
354
|
properties: { bar: { type: 'integer' } }
|
|
338
|
-
}),
|
|
355
|
+
}, undefined),
|
|
339
356
|
'Wrong Schema Type not checked!'
|
|
340
357
|
);
|
|
341
358
|
t.false(
|
|
342
359
|
isObjectArrayControl(control, {
|
|
343
360
|
type: 'object',
|
|
344
361
|
properties: { foo: { type: 'array' } }
|
|
345
|
-
}),
|
|
362
|
+
}, undefined),
|
|
346
363
|
'Array Schema Type without items not checked!'
|
|
347
364
|
);
|
|
348
365
|
t.false(
|
|
@@ -354,7 +371,7 @@ test('tester isObjectArrayControl', t => {
|
|
|
354
371
|
items: [{ type: 'integer' }, { type: 'string' }]
|
|
355
372
|
}
|
|
356
373
|
}
|
|
357
|
-
}),
|
|
374
|
+
}, undefined),
|
|
358
375
|
'Array Schema Type with tuples not checked!'
|
|
359
376
|
);
|
|
360
377
|
t.false(
|
|
@@ -366,7 +383,7 @@ test('tester isObjectArrayControl', t => {
|
|
|
366
383
|
items: { type: 'integer' }
|
|
367
384
|
}
|
|
368
385
|
}
|
|
369
|
-
}),
|
|
386
|
+
}, undefined),
|
|
370
387
|
'Array Schema Type with wrong item type not checked!'
|
|
371
388
|
);
|
|
372
389
|
const schema: JsonSchema = {
|
|
@@ -384,7 +401,7 @@ test('tester isObjectArrayControl', t => {
|
|
|
384
401
|
}
|
|
385
402
|
}
|
|
386
403
|
};
|
|
387
|
-
t.true(isObjectArrayControl(control, schema));
|
|
404
|
+
t.true(isObjectArrayControl(control, schema, schema));
|
|
388
405
|
const schema_noType: JsonSchema = {
|
|
389
406
|
type: 'object',
|
|
390
407
|
properties: {
|
|
@@ -399,7 +416,7 @@ test('tester isObjectArrayControl', t => {
|
|
|
399
416
|
}
|
|
400
417
|
}
|
|
401
418
|
};
|
|
402
|
-
t.true(isObjectArrayControl(control, schema_noType));
|
|
419
|
+
t.true(isObjectArrayControl(control, schema_noType, schema_noType));
|
|
403
420
|
const schema_innerAllOf: JsonSchema = {
|
|
404
421
|
type: 'object',
|
|
405
422
|
properties: {
|
|
@@ -422,44 +439,66 @@ test('tester isObjectArrayControl', t => {
|
|
|
422
439
|
}
|
|
423
440
|
}
|
|
424
441
|
};
|
|
425
|
-
t.true(isObjectArrayControl(control, schema_innerAllOf));
|
|
442
|
+
t.true(isObjectArrayControl(control, schema_innerAllOf, schema_innerAllOf));
|
|
443
|
+
|
|
444
|
+
const schemaWithRefs = {
|
|
445
|
+
definitions: {
|
|
446
|
+
order: {
|
|
447
|
+
type: 'object',
|
|
448
|
+
properties: {
|
|
449
|
+
x: { type: 'integer' },
|
|
450
|
+
y: { type: 'integer' }
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
type: 'object',
|
|
455
|
+
properties: {
|
|
456
|
+
foo: {
|
|
457
|
+
type: 'array',
|
|
458
|
+
items: {
|
|
459
|
+
$ref: '#/definitions/order'
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
t.true(isObjectArrayControl(control, schemaWithRefs, schemaWithRefs));
|
|
426
465
|
});
|
|
427
466
|
|
|
428
467
|
test('isBooleanControl', t => {
|
|
429
|
-
t.false(isBooleanControl(undefined, undefined));
|
|
430
|
-
t.false(isBooleanControl(null, undefined));
|
|
431
|
-
t.false(isBooleanControl({ type: 'Foo' }, undefined));
|
|
432
|
-
t.false(isBooleanControl({ type: 'Control' }, undefined));
|
|
468
|
+
t.false(isBooleanControl(undefined, undefined, undefined));
|
|
469
|
+
t.false(isBooleanControl(null, undefined, undefined));
|
|
470
|
+
t.false(isBooleanControl({ type: 'Foo' }, undefined, undefined));
|
|
471
|
+
t.false(isBooleanControl({ type: 'Control' }, undefined, undefined));
|
|
433
472
|
t.false(
|
|
434
473
|
isBooleanControl(t.context.uischema, {
|
|
435
474
|
type: 'object',
|
|
436
475
|
properties: { foo: { type: 'string' } }
|
|
437
|
-
})
|
|
476
|
+
}, undefined)
|
|
438
477
|
);
|
|
439
478
|
t.false(
|
|
440
479
|
isBooleanControl(t.context.uischema, {
|
|
441
480
|
type: 'object',
|
|
442
481
|
properties: { foo: { type: 'string' }, bar: { type: 'boolean' } }
|
|
443
|
-
})
|
|
482
|
+
}, undefined)
|
|
444
483
|
);
|
|
445
484
|
t.true(
|
|
446
485
|
isBooleanControl(t.context.uischema, {
|
|
447
486
|
type: 'object',
|
|
448
487
|
properties: { foo: { type: 'boolean' } }
|
|
449
|
-
})
|
|
488
|
+
}, undefined)
|
|
450
489
|
);
|
|
451
490
|
});
|
|
452
491
|
|
|
453
492
|
test('test isDateControl', t => {
|
|
454
|
-
t.false(isDateControl(undefined, undefined));
|
|
455
|
-
t.false(isDateControl(null, undefined));
|
|
456
|
-
t.false(isDateControl({ type: 'Foo' }, undefined));
|
|
457
|
-
t.false(isDateControl({ type: 'Control' }, undefined));
|
|
493
|
+
t.false(isDateControl(undefined, undefined, undefined));
|
|
494
|
+
t.false(isDateControl(null, undefined, undefined));
|
|
495
|
+
t.false(isDateControl({ type: 'Foo' }, undefined, undefined));
|
|
496
|
+
t.false(isDateControl({ type: 'Control' }, undefined, undefined));
|
|
458
497
|
t.false(
|
|
459
498
|
isDateControl(t.context.uischema, {
|
|
460
499
|
type: 'object',
|
|
461
500
|
properties: { foo: { type: 'string' } }
|
|
462
|
-
})
|
|
501
|
+
}, undefined)
|
|
463
502
|
);
|
|
464
503
|
t.false(
|
|
465
504
|
isDateControl(t.context.uischema, {
|
|
@@ -471,25 +510,25 @@ test('test isDateControl', t => {
|
|
|
471
510
|
format: 'date'
|
|
472
511
|
}
|
|
473
512
|
}
|
|
474
|
-
})
|
|
513
|
+
}, undefined)
|
|
475
514
|
);
|
|
476
515
|
t.true(
|
|
477
516
|
isDateControl(t.context.uischema, {
|
|
478
517
|
type: 'object',
|
|
479
518
|
properties: { foo: { type: 'string', format: 'date' } }
|
|
480
|
-
})
|
|
519
|
+
}, undefined)
|
|
481
520
|
);
|
|
482
521
|
});
|
|
483
522
|
test('test isEnumControl', t => {
|
|
484
|
-
t.false(isEnumControl(undefined, undefined));
|
|
485
|
-
t.false(isEnumControl(null, undefined));
|
|
486
|
-
t.false(isEnumControl({ type: 'Foo' }, undefined));
|
|
487
|
-
t.false(isEnumControl({ type: 'Control' }, undefined));
|
|
523
|
+
t.false(isEnumControl(undefined, undefined, undefined));
|
|
524
|
+
t.false(isEnumControl(null, undefined, undefined));
|
|
525
|
+
t.false(isEnumControl({ type: 'Foo' }, undefined, undefined));
|
|
526
|
+
t.false(isEnumControl({ type: 'Control' }, undefined, undefined));
|
|
488
527
|
t.false(
|
|
489
528
|
isEnumControl(t.context.uischema, {
|
|
490
529
|
type: 'object',
|
|
491
530
|
properties: { foo: { type: 'string' } }
|
|
492
|
-
})
|
|
531
|
+
}, undefined)
|
|
493
532
|
);
|
|
494
533
|
t.false(
|
|
495
534
|
isEnumControl(t.context.uischema, {
|
|
@@ -503,109 +542,109 @@ test('test isEnumControl', t => {
|
|
|
503
542
|
enum: ['a', 'b']
|
|
504
543
|
}
|
|
505
544
|
}
|
|
506
|
-
})
|
|
545
|
+
}, undefined)
|
|
507
546
|
);
|
|
508
547
|
t.true(
|
|
509
548
|
isEnumControl(t.context.uischema, {
|
|
510
549
|
type: 'object',
|
|
511
550
|
properties: { foo: { type: 'string', enum: ['a', 'b'] } }
|
|
512
|
-
})
|
|
551
|
+
}, undefined)
|
|
513
552
|
);
|
|
514
553
|
t.true(
|
|
515
554
|
isEnumControl(t.context.uischema, {
|
|
516
555
|
type: 'object',
|
|
517
556
|
properties: { foo: { type: 'number', enum: [1, 2] } }
|
|
518
|
-
})
|
|
557
|
+
}, undefined)
|
|
519
558
|
);
|
|
520
559
|
t.true(
|
|
521
560
|
isEnumControl(t.context.uischema, {
|
|
522
561
|
type: 'object',
|
|
523
562
|
properties: { foo: { const: '1.0' } }
|
|
524
|
-
})
|
|
563
|
+
}, undefined)
|
|
525
564
|
);
|
|
526
565
|
});
|
|
527
566
|
test('test isIntegerControl', t => {
|
|
528
|
-
t.false(isIntegerControl(undefined, undefined));
|
|
529
|
-
t.false(isIntegerControl(null, undefined));
|
|
530
|
-
t.false(isIntegerControl({ type: 'Foo' }, undefined));
|
|
531
|
-
t.false(isIntegerControl({ type: 'Control' }, undefined));
|
|
567
|
+
t.false(isIntegerControl(undefined, undefined, undefined));
|
|
568
|
+
t.false(isIntegerControl(null, undefined, undefined));
|
|
569
|
+
t.false(isIntegerControl({ type: 'Foo' }, undefined, undefined));
|
|
570
|
+
t.false(isIntegerControl({ type: 'Control' }, undefined, undefined));
|
|
532
571
|
t.false(
|
|
533
572
|
isIntegerControl(t.context.uischema, {
|
|
534
573
|
type: 'object',
|
|
535
574
|
properties: { foo: { type: 'string' } }
|
|
536
|
-
})
|
|
575
|
+
}, undefined)
|
|
537
576
|
);
|
|
538
577
|
t.false(
|
|
539
578
|
isIntegerControl(t.context.uischema, {
|
|
540
579
|
type: 'object',
|
|
541
580
|
properties: { foo: { type: 'string' }, bar: { type: 'integer' } }
|
|
542
|
-
})
|
|
581
|
+
}, undefined)
|
|
543
582
|
);
|
|
544
583
|
t.true(
|
|
545
584
|
isIntegerControl(t.context.uischema, {
|
|
546
585
|
type: 'object',
|
|
547
586
|
properties: { foo: { type: 'integer' } }
|
|
548
|
-
})
|
|
587
|
+
}, undefined)
|
|
549
588
|
);
|
|
550
589
|
});
|
|
551
590
|
test('test isNumberControl', t => {
|
|
552
|
-
t.false(isNumberControl(undefined, undefined));
|
|
553
|
-
t.false(isNumberControl(null, undefined));
|
|
554
|
-
t.false(isNumberControl({ type: 'Foo' }, undefined));
|
|
555
|
-
t.false(isNumberControl({ type: 'Control' }, undefined));
|
|
591
|
+
t.false(isNumberControl(undefined, undefined, undefined));
|
|
592
|
+
t.false(isNumberControl(null, undefined, undefined));
|
|
593
|
+
t.false(isNumberControl({ type: 'Foo' }, undefined, undefined));
|
|
594
|
+
t.false(isNumberControl({ type: 'Control' }, undefined, undefined));
|
|
556
595
|
t.false(
|
|
557
596
|
isNumberControl(t.context.uischema, {
|
|
558
597
|
type: 'object',
|
|
559
598
|
properties: { foo: { type: 'string' } }
|
|
560
|
-
})
|
|
599
|
+
}, undefined)
|
|
561
600
|
);
|
|
562
601
|
t.false(
|
|
563
602
|
isNumberControl(t.context.uischema, {
|
|
564
603
|
type: 'object',
|
|
565
604
|
properties: { foo: { type: 'string' }, bar: { type: 'number' } }
|
|
566
|
-
})
|
|
605
|
+
}, undefined)
|
|
567
606
|
);
|
|
568
607
|
t.true(
|
|
569
608
|
isNumberControl(t.context.uischema, {
|
|
570
609
|
type: 'object',
|
|
571
610
|
properties: { foo: { type: 'number' } }
|
|
572
|
-
})
|
|
611
|
+
}, undefined)
|
|
573
612
|
);
|
|
574
613
|
});
|
|
575
614
|
test('tester isStringControl', t => {
|
|
576
|
-
t.false(isStringControl(undefined, undefined));
|
|
577
|
-
t.false(isStringControl(null, undefined));
|
|
578
|
-
t.false(isStringControl({ type: 'Foo' }, undefined));
|
|
579
|
-
t.false(isStringControl({ type: 'Control' }, undefined));
|
|
615
|
+
t.false(isStringControl(undefined, undefined, undefined));
|
|
616
|
+
t.false(isStringControl(null, undefined, undefined));
|
|
617
|
+
t.false(isStringControl({ type: 'Foo' }, undefined, undefined));
|
|
618
|
+
t.false(isStringControl({ type: 'Control' }, undefined, undefined));
|
|
580
619
|
t.false(
|
|
581
620
|
isStringControl(t.context.uischema, {
|
|
582
621
|
type: 'object',
|
|
583
622
|
properties: { foo: { type: 'number' } }
|
|
584
|
-
})
|
|
623
|
+
}, undefined)
|
|
585
624
|
);
|
|
586
625
|
t.false(
|
|
587
626
|
isStringControl(t.context.uischema, {
|
|
588
627
|
type: 'object',
|
|
589
628
|
properties: { foo: { type: 'number' }, bar: { type: 'string' } }
|
|
590
|
-
})
|
|
629
|
+
}, undefined)
|
|
591
630
|
);
|
|
592
631
|
t.true(
|
|
593
632
|
isStringControl(t.context.uischema, {
|
|
594
633
|
type: 'object',
|
|
595
634
|
properties: { foo: { type: 'string' } }
|
|
596
|
-
})
|
|
635
|
+
}, undefined)
|
|
597
636
|
);
|
|
598
637
|
});
|
|
599
638
|
test('test isTimeControl', t => {
|
|
600
|
-
t.false(isTimeControl(undefined, undefined));
|
|
601
|
-
t.false(isTimeControl(null, undefined));
|
|
602
|
-
t.false(isTimeControl({ type: 'Foo' }, undefined));
|
|
603
|
-
t.false(isTimeControl({ type: 'Control' }, undefined));
|
|
639
|
+
t.false(isTimeControl(undefined, undefined, undefined));
|
|
640
|
+
t.false(isTimeControl(null, undefined, undefined));
|
|
641
|
+
t.false(isTimeControl({ type: 'Foo' }, undefined, undefined));
|
|
642
|
+
t.false(isTimeControl({ type: 'Control' }, undefined, undefined));
|
|
604
643
|
t.false(
|
|
605
644
|
isTimeControl(t.context.uischema, {
|
|
606
645
|
type: 'object',
|
|
607
646
|
properties: { foo: { type: 'string' } }
|
|
608
|
-
})
|
|
647
|
+
}, undefined)
|
|
609
648
|
);
|
|
610
649
|
t.false(
|
|
611
650
|
isTimeControl(t.context.uischema, {
|
|
@@ -614,25 +653,25 @@ test('test isTimeControl', t => {
|
|
|
614
653
|
foo: { type: 'string' },
|
|
615
654
|
bar: { type: 'string', format: 'time' }
|
|
616
655
|
}
|
|
617
|
-
})
|
|
656
|
+
}, undefined)
|
|
618
657
|
);
|
|
619
658
|
t.true(
|
|
620
659
|
isTimeControl(t.context.uischema, {
|
|
621
660
|
type: 'object',
|
|
622
661
|
properties: { foo: { type: 'string', format: 'time' } }
|
|
623
|
-
})
|
|
662
|
+
}, undefined)
|
|
624
663
|
);
|
|
625
664
|
});
|
|
626
665
|
test('tester isMultiLineControl', t => {
|
|
627
|
-
t.false(isMultiLineControl(undefined, undefined));
|
|
628
|
-
t.false(isMultiLineControl(null, undefined));
|
|
629
|
-
t.false(isMultiLineControl({ type: 'Foo' }, undefined));
|
|
630
|
-
t.false(isMultiLineControl({ type: 'Control' }, undefined));
|
|
666
|
+
t.false(isMultiLineControl(undefined, undefined, undefined));
|
|
667
|
+
t.false(isMultiLineControl(null, undefined, undefined));
|
|
668
|
+
t.false(isMultiLineControl({ type: 'Foo' }, undefined, undefined));
|
|
669
|
+
t.false(isMultiLineControl({ type: 'Control' }, undefined, undefined));
|
|
631
670
|
t.false(
|
|
632
671
|
isMultiLineControl(t.context.uischema, {
|
|
633
672
|
type: 'object',
|
|
634
673
|
properties: { foo: { type: 'string' } }
|
|
635
|
-
})
|
|
674
|
+
}, undefined)
|
|
636
675
|
);
|
|
637
676
|
const control = t.context.uischema;
|
|
638
677
|
control.options = { multi: true };
|
|
@@ -640,7 +679,7 @@ test('tester isMultiLineControl', t => {
|
|
|
640
679
|
isMultiLineControl(control, {
|
|
641
680
|
type: 'object',
|
|
642
681
|
properties: { foo: { type: 'string' } }
|
|
643
|
-
})
|
|
682
|
+
}, undefined)
|
|
644
683
|
);
|
|
645
684
|
});
|
|
646
685
|
|
|
@@ -709,6 +748,15 @@ test('tester isObjectArrayWithNesting', t => {
|
|
|
709
748
|
}
|
|
710
749
|
};
|
|
711
750
|
|
|
751
|
+
const nestedSchemaWithRef =
|
|
752
|
+
{
|
|
753
|
+
definitions: { itemsType: { ...schema } },
|
|
754
|
+
type: 'array',
|
|
755
|
+
items: {
|
|
756
|
+
$ref: '#/definitions/itemsType'
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
|
|
712
760
|
const uischemaOptions: {
|
|
713
761
|
generate: ControlElement;
|
|
714
762
|
default: ControlElement;
|
|
@@ -745,18 +793,19 @@ test('tester isObjectArrayWithNesting', t => {
|
|
|
745
793
|
}
|
|
746
794
|
};
|
|
747
795
|
|
|
748
|
-
t.false(isObjectArrayWithNesting(undefined, undefined));
|
|
749
|
-
t.false(isObjectArrayWithNesting(null, undefined));
|
|
750
|
-
t.false(isObjectArrayWithNesting({ type: 'Foo' }, undefined));
|
|
751
|
-
t.false(isObjectArrayWithNesting({ type: 'Control' }, undefined));
|
|
752
|
-
t.false(isObjectArrayWithNesting(uischema, schema));
|
|
753
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema));
|
|
754
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema2));
|
|
755
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema3));
|
|
796
|
+
t.false(isObjectArrayWithNesting(undefined, undefined, undefined));
|
|
797
|
+
t.false(isObjectArrayWithNesting(null, undefined, undefined));
|
|
798
|
+
t.false(isObjectArrayWithNesting({ type: 'Foo' }, undefined, undefined));
|
|
799
|
+
t.false(isObjectArrayWithNesting({ type: 'Control' }, undefined, undefined));
|
|
800
|
+
t.false(isObjectArrayWithNesting(uischema, schema, undefined));
|
|
801
|
+
t.true(isObjectArrayWithNesting(uischema, nestedSchema, undefined));
|
|
802
|
+
t.true(isObjectArrayWithNesting(uischema, nestedSchema2, undefined));
|
|
803
|
+
t.true(isObjectArrayWithNesting(uischema, nestedSchema3, undefined));
|
|
804
|
+
t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithRef, nestedSchemaWithRef));
|
|
756
805
|
|
|
757
|
-
t.false(isObjectArrayWithNesting(uischemaOptions.default, schema));
|
|
758
|
-
t.true(isObjectArrayWithNesting(uischemaOptions.generate, schema));
|
|
759
|
-
t.true(isObjectArrayWithNesting(uischemaOptions.inline, schema));
|
|
806
|
+
t.false(isObjectArrayWithNesting(uischemaOptions.default, schema, undefined));
|
|
807
|
+
t.true(isObjectArrayWithNesting(uischemaOptions.generate, schema, undefined));
|
|
808
|
+
t.true(isObjectArrayWithNesting(uischemaOptions.inline, schema, undefined));
|
|
760
809
|
});
|
|
761
810
|
|
|
762
811
|
test('tester schemaSubPathMatches', t => {
|
|
@@ -771,10 +820,12 @@ test('tester schemaSubPathMatches', t => {
|
|
|
771
820
|
type: 'Control',
|
|
772
821
|
scope: '#'
|
|
773
822
|
};
|
|
823
|
+
|
|
774
824
|
t.true(
|
|
775
825
|
schemaSubPathMatches('items', items => items.type === 'number')(
|
|
776
826
|
uischema,
|
|
777
|
-
schema
|
|
827
|
+
schema,
|
|
828
|
+
undefined
|
|
778
829
|
)
|
|
779
830
|
);
|
|
780
831
|
});
|
|
@@ -783,6 +834,43 @@ test('tester not', t => {
|
|
|
783
834
|
t.false(
|
|
784
835
|
not(isBooleanControl)(t.context.uischema, {
|
|
785
836
|
type: 'boolean'
|
|
786
|
-
})
|
|
837
|
+
}, undefined)
|
|
787
838
|
);
|
|
788
839
|
});
|
|
840
|
+
|
|
841
|
+
test('tester isOneOfEnumControl', t => {
|
|
842
|
+
const control: ControlElement = {
|
|
843
|
+
type: 'Control',
|
|
844
|
+
scope: '#/properties/country'
|
|
845
|
+
};
|
|
846
|
+
const oneOfSchema = {
|
|
847
|
+
type: 'string',
|
|
848
|
+
oneOf: [
|
|
849
|
+
{
|
|
850
|
+
const: 'AU',
|
|
851
|
+
title: 'Australia'
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
const: 'NZ',
|
|
855
|
+
title: 'New Zealand'
|
|
856
|
+
}
|
|
857
|
+
]
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
t.true(isOneOfEnumControl(control, {
|
|
861
|
+
type: 'object',
|
|
862
|
+
properties: {
|
|
863
|
+
country: oneOfSchema
|
|
864
|
+
}
|
|
865
|
+
}, undefined));
|
|
866
|
+
const schemaWithRefs = {
|
|
867
|
+
definitions: { country: oneOfSchema },
|
|
868
|
+
type: 'object',
|
|
869
|
+
properties: {
|
|
870
|
+
country: {
|
|
871
|
+
$ref: '#/definitions/country'
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
t.true(isOneOfEnumControl(control, schemaWithRefs, schemaWithRefs));
|
|
876
|
+
});
|