@jsonforms/core 3.1.0-alpha.0 → 3.1.0-alpha.1
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/lib/Helpers.d.ts +1 -1
- package/lib/actions/actions.d.ts +6 -5
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/i18n/i18nTypes.d.ts +3 -2
- package/lib/i18n/i18nUtil.d.ts +2 -2
- package/lib/jsonforms-core.cjs.js +3 -3
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +2 -2
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/jsonSchema.d.ts +2 -2
- package/lib/models/uischema.d.ts +1 -1
- package/lib/reducers/cells.d.ts +2 -2
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/core.d.ts +3 -2
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/i18n.d.ts +1 -1
- package/lib/reducers/reducers.d.ts +4 -4
- package/lib/reducers/renderers.d.ts +2 -2
- package/lib/reducers/selectors.d.ts +6 -6
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/store.d.ts +3 -3
- package/lib/testers/testers.d.ts +1 -1
- package/lib/util/cell.d.ts +3 -3
- package/lib/util/combinators.d.ts +1 -1
- package/lib/util/label.d.ts +1 -1
- package/lib/util/path.d.ts +6 -3
- package/lib/util/renderer.d.ts +5 -5
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/runtime.d.ts +2 -2
- package/lib/util/util.d.ts +2 -2
- package/lib/util/validator.d.ts +1 -1
- package/package.json +7 -3
- package/src/Helpers.ts +1 -1
- package/src/actions/actions.ts +6 -5
- package/src/generators/Generate.ts +1 -1
- package/src/generators/schema.ts +1 -1
- package/src/i18n/i18nTypes.ts +3 -2
- package/src/i18n/i18nUtil.ts +2 -2
- package/src/models/jsonSchema.ts +2 -2
- package/src/models/uischema.ts +1 -1
- package/src/reducers/cells.ts +2 -2
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +4 -3
- package/src/reducers/default-data.ts +1 -1
- package/src/reducers/i18n.ts +1 -1
- package/src/reducers/reducers.ts +4 -4
- package/src/reducers/renderers.ts +2 -2
- package/src/reducers/selectors.ts +6 -6
- package/src/reducers/uischemas.ts +2 -2
- package/src/store.ts +3 -3
- package/src/testers/testers.ts +2 -2
- package/src/util/cell.ts +3 -3
- package/src/util/combinators.ts +1 -1
- package/src/util/label.ts +1 -1
- package/src/util/path.ts +6 -3
- package/src/util/renderer.ts +5 -5
- package/src/util/resolvers.ts +2 -2
- package/src/util/runtime.ts +2 -2
- package/src/util/util.ts +2 -2
- package/src/util/validator.ts +1 -1
- package/.nycrc +0 -6
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/gen.html +0 -406
- package/docs/enums/ruleeffect.html +0 -214
- package/docs/globals.html +0 -10568
- package/docs/index.html +0 -1297
- package/docs/interfaces/action.html +0 -166
- package/docs/interfaces/addcellrendereraction.html +0 -181
- package/docs/interfaces/addrendereraction.html +0 -181
- package/docs/interfaces/adduischemaaction.html +0 -181
- package/docs/interfaces/andcondition.html +0 -181
- package/docs/interfaces/anyaction.html +0 -189
- package/docs/interfaces/arraycontrolprops.html +0 -653
- package/docs/interfaces/arraylayoutprops.html +0 -648
- package/docs/interfaces/categorization.html +0 -281
- package/docs/interfaces/category.html +0 -279
- package/docs/interfaces/cellprops.html +0 -452
- package/docs/interfaces/combinatorrendererprops.html +0 -503
- package/docs/interfaces/combinatorsubschemarenderinfo.html +0 -181
- package/docs/interfaces/composablecondition.html +0 -193
- package/docs/interfaces/condition.html +0 -176
- package/docs/interfaces/controlelement.html +0 -280
- package/docs/interfaces/controlprops.html +0 -497
- package/docs/interfaces/controlstate.html +0 -184
- package/docs/interfaces/controlwithdetailprops.html +0 -501
- package/docs/interfaces/dispatchcellprops.html +0 -388
- package/docs/interfaces/dispatchcellstateprops.html +0 -408
- package/docs/interfaces/dispatchpropsofarraycontrol.html +0 -322
- package/docs/interfaces/dispatchpropsofcontrol.html +0 -204
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +0 -215
- package/docs/interfaces/enumcellprops.html +0 -467
- package/docs/interfaces/enumoption.html +0 -167
- package/docs/interfaces/formatted.html +0 -226
- package/docs/interfaces/grouplayout.html +0 -284
- package/docs/interfaces/horizontallayout.html +0 -234
- package/docs/interfaces/initaction.html +0 -209
- package/docs/interfaces/initactionoptions.html +0 -181
- package/docs/interfaces/internationalizable.html +0 -170
- package/docs/interfaces/jsonformscellrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformscore.html +0 -251
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +0 -167
- package/docs/interfaces/jsonformsextendedstate.html +0 -175
- package/docs/interfaces/jsonformsi18nstate.html +0 -181
- package/docs/interfaces/jsonformsprops.html +0 -321
- package/docs/interfaces/jsonformsrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformsstate.html +0 -170
- package/docs/interfaces/jsonformsstore.html +0 -376
- package/docs/interfaces/jsonformssubstates.html +0 -276
- package/docs/interfaces/jsonformsuischemaregistryentry.html +0 -167
- package/docs/interfaces/jsonschema4.html +0 -758
- package/docs/interfaces/jsonschema7.html +0 -884
- package/docs/interfaces/labelable.html +0 -184
- package/docs/interfaces/labeldescription.html +0 -184
- package/docs/interfaces/labeled.html +0 -182
- package/docs/interfaces/labelelement.html +0 -251
- package/docs/interfaces/labelprops.html +0 -339
- package/docs/interfaces/layout.html +0 -253
- package/docs/interfaces/layoutprops.html +0 -359
- package/docs/interfaces/leafcondition.html +0 -209
- package/docs/interfaces/orcondition.html +0 -181
- package/docs/interfaces/ownpropsofcell.html +0 -321
- package/docs/interfaces/ownpropsofcontrol.html +0 -305
- package/docs/interfaces/ownpropsofenum.html +0 -161
- package/docs/interfaces/ownpropsofenumcell.html +0 -335
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +0 -296
- package/docs/interfaces/ownpropsoflabel.html +0 -286
- package/docs/interfaces/ownpropsoflayout.html +0 -305
- package/docs/interfaces/ownpropsofmasterlistitem.html +0 -289
- package/docs/interfaces/ownpropsofrenderer.html +0 -292
- package/docs/interfaces/referenceschemamap.html +0 -138
- package/docs/interfaces/registerdefaultdataaction.html +0 -181
- package/docs/interfaces/removecellrendereraction.html +0 -181
- package/docs/interfaces/removerendereraction.html +0 -181
- package/docs/interfaces/removeuischemaaction.html +0 -167
- package/docs/interfaces/rendererprops.html +0 -331
- package/docs/interfaces/rule.html +0 -185
- package/docs/interfaces/schemabasedcondition.html +0 -202
- package/docs/interfaces/scopable.html +0 -171
- package/docs/interfaces/scoped.html +0 -183
- package/docs/interfaces/setajvaction.html +0 -167
- package/docs/interfaces/setconfigaction.html +0 -167
- package/docs/interfaces/setlocaleaction.html +0 -167
- package/docs/interfaces/setschemaaction.html +0 -167
- package/docs/interfaces/settranslatoraction.html +0 -181
- package/docs/interfaces/setuischemaaction.html +0 -167
- package/docs/interfaces/setvalidationmodeaction.html +0 -167
- package/docs/interfaces/statepropsofarraycontrol.html +0 -474
- package/docs/interfaces/statepropsofarraylayout.html +0 -461
- package/docs/interfaces/statepropsofcell.html +0 -408
- package/docs/interfaces/statepropsofcombinator.html +0 -449
- package/docs/interfaces/statepropsofcontrol.html +0 -451
- package/docs/interfaces/statepropsofcontrolwithdetail.html +0 -463
- package/docs/interfaces/statepropsofenumcell.html +0 -422
- package/docs/interfaces/statepropsofjsonformsrenderer.html +0 -324
- package/docs/interfaces/statepropsoflabel.html +0 -343
- package/docs/interfaces/statepropsoflayout.html +0 -369
- package/docs/interfaces/statepropsofmasteritem.html +0 -309
- package/docs/interfaces/statepropsofrenderer.html +0 -331
- package/docs/interfaces/statepropsofscopedrenderer.html +0 -391
- package/docs/interfaces/store.html +0 -386
- package/docs/interfaces/testercontext.html +0 -184
- package/docs/interfaces/uischemaelement.html +0 -225
- package/docs/interfaces/unregisterdefaultdataaction.html +0 -167
- package/docs/interfaces/updateaction.html +0 -202
- package/docs/interfaces/updatecoreaction.html +0 -209
- package/docs/interfaces/updateerrorsaction.html +0 -167
- package/docs/interfaces/updatei18naction.html +0 -195
- package/docs/interfaces/verticallayout.html +0 -234
- package/docs/interfaces/withclassname.html +0 -153
- package/rollup.config.js +0 -44
- package/stats.html +0 -3279
- package/test/actions/actions.test.ts +0 -93
- package/test/generators/schema.test.ts +0 -224
- package/test/generators/uischema.test.ts +0 -576
- package/test/i18n/i18nUtil.test.ts +0 -88
- package/test/reducers/core.test.ts +0 -1682
- package/test/reducers/uischemas.test.ts +0 -173
- package/test/testers.test.ts +0 -948
- package/test/util/array.test.ts +0 -28
- package/test/util/cell.test.ts +0 -354
- package/test/util/derivetype.test.ts +0 -101
- package/test/util/label.test.ts +0 -364
- package/test/util/path.test.ts +0 -259
- package/test/util/renderer.test.ts +0 -1830
- package/test/util/resolvers.test.ts +0 -157
- package/test/util/runtime.test.ts +0 -779
- package/tsconfig.json +0 -13
package/test/testers.test.ts
DELETED
|
@@ -1,948 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import anyTest, { TestInterface } from 'ava';
|
|
26
|
-
import {
|
|
27
|
-
and,
|
|
28
|
-
formatIs,
|
|
29
|
-
isBooleanControl,
|
|
30
|
-
isDateControl,
|
|
31
|
-
isEnumControl,
|
|
32
|
-
isIntegerControl,
|
|
33
|
-
isMultiLineControl,
|
|
34
|
-
isNumberControl,
|
|
35
|
-
isObjectArrayControl,
|
|
36
|
-
isObjectArrayWithNesting,
|
|
37
|
-
isPrimitiveArrayControl,
|
|
38
|
-
isStringControl,
|
|
39
|
-
isTimeControl,
|
|
40
|
-
not,
|
|
41
|
-
optionIs,
|
|
42
|
-
or,
|
|
43
|
-
schemaMatches,
|
|
44
|
-
schemaSubPathMatches,
|
|
45
|
-
schemaTypeIs,
|
|
46
|
-
scopeEndIs,
|
|
47
|
-
scopeEndsWith,
|
|
48
|
-
uiTypeIs,
|
|
49
|
-
isOneOfEnumControl,
|
|
50
|
-
TesterContext
|
|
51
|
-
} from '../src/testers';
|
|
52
|
-
import {
|
|
53
|
-
ControlElement,
|
|
54
|
-
JsonSchema,
|
|
55
|
-
LabelElement,
|
|
56
|
-
UISchemaElement
|
|
57
|
-
} from '../src';
|
|
58
|
-
|
|
59
|
-
const test = anyTest as TestInterface<{ uischema: ControlElement }>;
|
|
60
|
-
|
|
61
|
-
const createTesterContext =
|
|
62
|
-
(rootSchema: JsonSchema, config?: any): TesterContext => ({ rootSchema, config });
|
|
63
|
-
|
|
64
|
-
test.beforeEach(t => {
|
|
65
|
-
t.context.uischema = {
|
|
66
|
-
type: 'Control',
|
|
67
|
-
scope: '#/properties/foo'
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('schemaTypeIs should check type sub-schema of control', t => {
|
|
72
|
-
const schema: JsonSchema = {
|
|
73
|
-
type: 'object',
|
|
74
|
-
properties: {
|
|
75
|
-
foo: { type: 'string' }
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const uischema: ControlElement = {
|
|
79
|
-
type: 'Control',
|
|
80
|
-
scope: '#/properties/foo'
|
|
81
|
-
};
|
|
82
|
-
const testerContext = createTesterContext(schema);
|
|
83
|
-
t.true(schemaTypeIs('string')(uischema, schema, testerContext));
|
|
84
|
-
t.false(schemaTypeIs('integer')(uischema, schema, testerContext));
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('schemaTypeIs should return false for non-control UI schema elements', t => {
|
|
88
|
-
const schema: JsonSchema = {
|
|
89
|
-
type: 'object',
|
|
90
|
-
properties: {
|
|
91
|
-
foo: { type: 'string' }
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
const label: LabelElement = {
|
|
95
|
-
type: 'Label',
|
|
96
|
-
text: 'some text'
|
|
97
|
-
};
|
|
98
|
-
const testerContext = createTesterContext(schema);
|
|
99
|
-
t.false(schemaTypeIs('integer')(label, schema, testerContext));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('schemaTypeIs should return false for control pointing to invalid sub-schema', t => {
|
|
103
|
-
const uischema: ControlElement = {
|
|
104
|
-
type: 'Control',
|
|
105
|
-
scope: '#/properties/bar'
|
|
106
|
-
};
|
|
107
|
-
const schema: JsonSchema = {
|
|
108
|
-
type: 'object',
|
|
109
|
-
properties: {
|
|
110
|
-
foo: { type: 'string' }
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const testerContext = createTesterContext(schema);
|
|
114
|
-
t.false(schemaTypeIs('string')(uischema, schema, testerContext));
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('schemaTypeIs should return true for array type', t => {
|
|
118
|
-
const schema: JsonSchema = {
|
|
119
|
-
type: 'object',
|
|
120
|
-
properties: {
|
|
121
|
-
foo: { type: ['string', 'integer'] }
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const uischema: ControlElement = {
|
|
125
|
-
type: 'Control',
|
|
126
|
-
scope: '#/properties/foo'
|
|
127
|
-
};
|
|
128
|
-
const testerContext = createTesterContext(schema);
|
|
129
|
-
t.true(schemaTypeIs('string')(uischema, schema, testerContext));
|
|
130
|
-
t.true(schemaTypeIs('integer')(uischema, schema, testerContext));
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('formatIs should check the format of a resolved sub-schema', t => {
|
|
134
|
-
const uischema: ControlElement = {
|
|
135
|
-
type: 'Control',
|
|
136
|
-
scope: '#/properties/foo'
|
|
137
|
-
};
|
|
138
|
-
const schema: JsonSchema = {
|
|
139
|
-
type: 'object',
|
|
140
|
-
properties: {
|
|
141
|
-
foo: {
|
|
142
|
-
type: 'string',
|
|
143
|
-
format: 'date-time'
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
const testerContext = createTesterContext(schema);
|
|
148
|
-
t.true(formatIs('date-time')(uischema, schema, testerContext));
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('uiTypeIs', t => {
|
|
152
|
-
const control: ControlElement = {
|
|
153
|
-
type: 'Control',
|
|
154
|
-
scope: '#/properties/bar'
|
|
155
|
-
};
|
|
156
|
-
t.true(uiTypeIs('Control')(control, undefined, undefined));
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('optionIs should check for options', t => {
|
|
160
|
-
const control: ControlElement = {
|
|
161
|
-
type: 'Control',
|
|
162
|
-
scope: '#/properties/bar',
|
|
163
|
-
options: {
|
|
164
|
-
answer: 42
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
t.true(optionIs('answer', 42)(control, undefined, undefined));
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test('optionIs should not fail if uischema is undefined or null', t => {
|
|
171
|
-
const uischema: UISchemaElement = null;
|
|
172
|
-
t.false(optionIs('answer', 42)(uischema, undefined, undefined));
|
|
173
|
-
t.false(optionIs('answer', 42)(uischema, undefined, undefined));
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('optionIs should return false for UI schema elements without options cell', t => {
|
|
177
|
-
const control: ControlElement = {
|
|
178
|
-
type: 'Control',
|
|
179
|
-
scope: '#/properties/bar'
|
|
180
|
-
};
|
|
181
|
-
t.false(optionIs('answer', 42)(control, undefined, undefined));
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('schemaMatches should check type sub-schema of control via predicate', t => {
|
|
185
|
-
const schema: JsonSchema = {
|
|
186
|
-
type: 'object',
|
|
187
|
-
properties: {
|
|
188
|
-
foo: { type: 'string' }
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const uischema: ControlElement = {
|
|
192
|
-
type: 'Control',
|
|
193
|
-
scope: '#/properties/foo'
|
|
194
|
-
};
|
|
195
|
-
const testerContext = createTesterContext(schema);
|
|
196
|
-
t.true(
|
|
197
|
-
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, testerContext)
|
|
198
|
-
);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
test('schemaMatches should check type sub-schema of control via predicate also without explicit type', t => {
|
|
202
|
-
const schema: JsonSchema = {
|
|
203
|
-
properties: {
|
|
204
|
-
foo: { type: 'string' }
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
const uischema: ControlElement = {
|
|
208
|
-
type: 'Control',
|
|
209
|
-
scope: '#/properties/foo'
|
|
210
|
-
};
|
|
211
|
-
const testerContext = createTesterContext(schema);
|
|
212
|
-
t.true(
|
|
213
|
-
schemaMatches(subSchema => subSchema.type === 'string')(uischema, schema, testerContext)
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
test('schemaMatches should return false for non-control UI schema elements', t => {
|
|
218
|
-
const schema: JsonSchema = {
|
|
219
|
-
type: 'object',
|
|
220
|
-
properties: {
|
|
221
|
-
foo: { type: 'string' }
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
const label: LabelElement = {
|
|
225
|
-
type: 'Label',
|
|
226
|
-
text: 'some text'
|
|
227
|
-
};
|
|
228
|
-
const testerContext = createTesterContext(schema);
|
|
229
|
-
t.false(schemaMatches(() => false)(label, schema, testerContext));
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test('schemaMatches should return false for control pointing to invalid subschema', t => {
|
|
233
|
-
const schema: JsonSchema = {
|
|
234
|
-
type: 'object',
|
|
235
|
-
properties: {
|
|
236
|
-
foo: { type: 'string' }
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
const uischema: ControlElement = {
|
|
240
|
-
type: 'Control',
|
|
241
|
-
scope: '#/properties/bar'
|
|
242
|
-
};
|
|
243
|
-
const testerContext = createTesterContext(schema);
|
|
244
|
-
t.false(schemaMatches(() => false)(uischema, schema, testerContext));
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
test('scopeEndsWith checks whether the ref of a control ends with a certain string', t => {
|
|
248
|
-
const uischema: ControlElement = {
|
|
249
|
-
type: 'Control',
|
|
250
|
-
scope: '#/properties/bar'
|
|
251
|
-
};
|
|
252
|
-
t.true(scopeEndsWith('properties/bar')(uischema, undefined, undefined));
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test('scopeEndsWith should return false for non-control UI schema elements', t => {
|
|
256
|
-
const label: LabelElement = {
|
|
257
|
-
type: 'Label',
|
|
258
|
-
text: 'some text'
|
|
259
|
-
};
|
|
260
|
-
t.false(scopeEndsWith('properties/bar')(label, undefined, undefined));
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test('refEndIs checks whether the last segment a control ref equals a certain string', t => {
|
|
264
|
-
const uischema: ControlElement = {
|
|
265
|
-
type: 'Control',
|
|
266
|
-
scope: '#/properties/bar'
|
|
267
|
-
};
|
|
268
|
-
t.true(scopeEndIs('bar')(uischema, undefined, undefined));
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
test('refEndIs should return false for non-control UI schema elements', t => {
|
|
272
|
-
const label: LabelElement = {
|
|
273
|
-
type: 'Label',
|
|
274
|
-
text: 'some text'
|
|
275
|
-
};
|
|
276
|
-
t.false(scopeEndIs('bar')(label, undefined, undefined));
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
test('and should allow to compose multiple testers', t => {
|
|
280
|
-
const schema: JsonSchema = {
|
|
281
|
-
type: 'object',
|
|
282
|
-
properties: {
|
|
283
|
-
foo: { type: 'string' }
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
const uischema: ControlElement = {
|
|
287
|
-
type: 'Control',
|
|
288
|
-
scope: '#/properties/foo'
|
|
289
|
-
};
|
|
290
|
-
const testerContext = createTesterContext(schema);
|
|
291
|
-
t.true(and(schemaTypeIs('string'), scopeEndIs('foo'))(uischema, schema, testerContext));
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
test('or should allow to compose multiple testers', t => {
|
|
295
|
-
const schema: JsonSchema = {
|
|
296
|
-
type: 'object',
|
|
297
|
-
properties: {
|
|
298
|
-
foo: { type: 'integer' }
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
const uischema: ControlElement = {
|
|
302
|
-
type: 'Control',
|
|
303
|
-
scope: '#/properties/foo'
|
|
304
|
-
};
|
|
305
|
-
const testerContext = createTesterContext(schema);
|
|
306
|
-
t.true(
|
|
307
|
-
or(schemaTypeIs('integer'), optionIs('slider', true))(uischema, schema, testerContext)
|
|
308
|
-
);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test('tester isPrimitiveArrayControl', t => {
|
|
312
|
-
const control: ControlElement = {
|
|
313
|
-
type: 'Control',
|
|
314
|
-
scope: '#/properties/foo'
|
|
315
|
-
};
|
|
316
|
-
const schema = {
|
|
317
|
-
type: 'object',
|
|
318
|
-
properties: {
|
|
319
|
-
foo: {
|
|
320
|
-
type: 'array',
|
|
321
|
-
items: { type: 'integer' }
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
t.true(
|
|
326
|
-
isPrimitiveArrayControl(control, schema, createTesterContext(schema)),
|
|
327
|
-
`Primitive array tester was not triggered for 'integer' schema type`
|
|
328
|
-
);
|
|
329
|
-
const schemaWithRefs = {
|
|
330
|
-
definitions: { int: { type: 'integer' } },
|
|
331
|
-
type: 'object',
|
|
332
|
-
properties: {
|
|
333
|
-
foo: {
|
|
334
|
-
type: 'array',
|
|
335
|
-
items: { $ref: '#/definitions/int' }
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
t.true(
|
|
340
|
-
isPrimitiveArrayControl(control, schemaWithRefs, createTesterContext(schemaWithRefs)),
|
|
341
|
-
`Primitive array tester was not triggered for 'integer' schema type with refs`
|
|
342
|
-
);
|
|
343
|
-
const objectSchema = {
|
|
344
|
-
type: 'object',
|
|
345
|
-
properties: {
|
|
346
|
-
foo: {
|
|
347
|
-
type: 'array',
|
|
348
|
-
items: { type: 'object' }
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
t.false(
|
|
353
|
-
isPrimitiveArrayControl(control, objectSchema, createTesterContext(objectSchema)),
|
|
354
|
-
`Primitive array tester was not triggered for 'object' schema type`
|
|
355
|
-
);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
test('tester isObjectArrayControl', t => {
|
|
359
|
-
t.false(isObjectArrayControl({ type: 'Foo' }, null, null));
|
|
360
|
-
const control: ControlElement = {
|
|
361
|
-
type: 'Control',
|
|
362
|
-
scope: '#/properties/foo'
|
|
363
|
-
};
|
|
364
|
-
t.false(isObjectArrayControl(control, undefined, undefined), 'No Schema not checked!');
|
|
365
|
-
|
|
366
|
-
t.false(
|
|
367
|
-
isObjectArrayControl(control, {
|
|
368
|
-
type: 'object',
|
|
369
|
-
properties: { bar: { type: 'integer' } }
|
|
370
|
-
}, undefined),
|
|
371
|
-
'Wrong Schema Type not checked!'
|
|
372
|
-
);
|
|
373
|
-
t.false(
|
|
374
|
-
isObjectArrayControl(control, {
|
|
375
|
-
type: 'object',
|
|
376
|
-
properties: { foo: { type: 'array' } }
|
|
377
|
-
}, undefined),
|
|
378
|
-
'Array Schema Type without items not checked!'
|
|
379
|
-
);
|
|
380
|
-
t.false(
|
|
381
|
-
isObjectArrayControl(control, {
|
|
382
|
-
type: 'object',
|
|
383
|
-
properties: {
|
|
384
|
-
foo: {
|
|
385
|
-
type: 'array',
|
|
386
|
-
items: [{ type: 'integer' }, { type: 'string' }]
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}, undefined),
|
|
390
|
-
'Array Schema Type with tuples not checked!'
|
|
391
|
-
);
|
|
392
|
-
t.false(
|
|
393
|
-
isObjectArrayControl(control, {
|
|
394
|
-
type: 'object',
|
|
395
|
-
properties: {
|
|
396
|
-
foo: {
|
|
397
|
-
type: 'array',
|
|
398
|
-
items: { type: 'integer' }
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}, undefined),
|
|
402
|
-
'Array Schema Type with wrong item type not checked!'
|
|
403
|
-
);
|
|
404
|
-
const schema: JsonSchema = {
|
|
405
|
-
type: 'object',
|
|
406
|
-
properties: {
|
|
407
|
-
foo: {
|
|
408
|
-
type: 'array',
|
|
409
|
-
items: {
|
|
410
|
-
type: 'object',
|
|
411
|
-
properties: {
|
|
412
|
-
x: { type: 'integer' },
|
|
413
|
-
y: { type: 'integer' }
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
t.true(isObjectArrayControl(control, schema, createTesterContext(schema)));
|
|
420
|
-
const schema_noType: JsonSchema = {
|
|
421
|
-
type: 'object',
|
|
422
|
-
properties: {
|
|
423
|
-
foo: {
|
|
424
|
-
items: {
|
|
425
|
-
type: 'object',
|
|
426
|
-
properties: {
|
|
427
|
-
x: { type: 'integer' },
|
|
428
|
-
y: { type: 'integer' }
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
t.true(isObjectArrayControl(control, schema_noType, createTesterContext(schema_noType)));
|
|
435
|
-
const schema_innerAllOf: JsonSchema = {
|
|
436
|
-
type: 'object',
|
|
437
|
-
properties: {
|
|
438
|
-
foo: {
|
|
439
|
-
type: 'array',
|
|
440
|
-
items: {
|
|
441
|
-
allOf: [
|
|
442
|
-
{
|
|
443
|
-
properties: {
|
|
444
|
-
x: { type: 'integer' }
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
properties: {
|
|
449
|
-
y: { type: 'integer' }
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
]
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
t.true(isObjectArrayControl(control, schema_innerAllOf, createTesterContext(schema_innerAllOf)));
|
|
458
|
-
|
|
459
|
-
const schemaWithRefs = {
|
|
460
|
-
definitions: {
|
|
461
|
-
order: {
|
|
462
|
-
type: 'object',
|
|
463
|
-
properties: {
|
|
464
|
-
x: { type: 'integer' },
|
|
465
|
-
y: { type: 'integer' }
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
},
|
|
469
|
-
type: 'object',
|
|
470
|
-
properties: {
|
|
471
|
-
foo: {
|
|
472
|
-
type: 'array',
|
|
473
|
-
items: {
|
|
474
|
-
$ref: '#/definitions/order'
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
const testerContext = createTesterContext(schemaWithRefs);
|
|
480
|
-
t.true(isObjectArrayControl(control, schemaWithRefs, testerContext));
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
test('isBooleanControl', t => {
|
|
484
|
-
t.false(isBooleanControl(undefined, undefined, undefined));
|
|
485
|
-
t.false(isBooleanControl(null, undefined, undefined));
|
|
486
|
-
t.false(isBooleanControl({ type: 'Foo' }, undefined, undefined));
|
|
487
|
-
t.false(isBooleanControl({ type: 'Control' }, undefined, undefined));
|
|
488
|
-
t.false(
|
|
489
|
-
isBooleanControl(t.context.uischema, {
|
|
490
|
-
type: 'object',
|
|
491
|
-
properties: { foo: { type: 'string' } }
|
|
492
|
-
}, undefined)
|
|
493
|
-
);
|
|
494
|
-
t.false(
|
|
495
|
-
isBooleanControl(t.context.uischema, {
|
|
496
|
-
type: 'object',
|
|
497
|
-
properties: { foo: { type: 'string' }, bar: { type: 'boolean' } }
|
|
498
|
-
}, undefined)
|
|
499
|
-
);
|
|
500
|
-
t.true(
|
|
501
|
-
isBooleanControl(t.context.uischema, {
|
|
502
|
-
type: 'object',
|
|
503
|
-
properties: { foo: { type: 'boolean' } }
|
|
504
|
-
}, undefined)
|
|
505
|
-
);
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
test('test isDateControl', t => {
|
|
509
|
-
t.false(isDateControl(undefined, undefined, undefined));
|
|
510
|
-
t.false(isDateControl(null, undefined, undefined));
|
|
511
|
-
t.false(isDateControl({ type: 'Foo' }, undefined, undefined));
|
|
512
|
-
t.false(isDateControl({ type: 'Control' }, undefined, undefined));
|
|
513
|
-
t.false(
|
|
514
|
-
isDateControl(t.context.uischema, {
|
|
515
|
-
type: 'object',
|
|
516
|
-
properties: { foo: { type: 'string' } }
|
|
517
|
-
}, undefined)
|
|
518
|
-
);
|
|
519
|
-
t.false(
|
|
520
|
-
isDateControl(t.context.uischema, {
|
|
521
|
-
type: 'object',
|
|
522
|
-
properties: {
|
|
523
|
-
foo: { type: 'string' },
|
|
524
|
-
bar: {
|
|
525
|
-
type: 'string',
|
|
526
|
-
format: 'date'
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}, undefined)
|
|
530
|
-
);
|
|
531
|
-
t.true(
|
|
532
|
-
isDateControl(t.context.uischema, {
|
|
533
|
-
type: 'object',
|
|
534
|
-
properties: { foo: { type: 'string', format: 'date' } }
|
|
535
|
-
}, undefined)
|
|
536
|
-
);
|
|
537
|
-
});
|
|
538
|
-
test('test isEnumControl', t => {
|
|
539
|
-
t.false(isEnumControl(undefined, undefined, undefined));
|
|
540
|
-
t.false(isEnumControl(null, undefined, undefined));
|
|
541
|
-
t.false(isEnumControl({ type: 'Foo' }, undefined, undefined));
|
|
542
|
-
t.false(isEnumControl({ type: 'Control' }, undefined, undefined));
|
|
543
|
-
t.false(
|
|
544
|
-
isEnumControl(t.context.uischema, {
|
|
545
|
-
type: 'object',
|
|
546
|
-
properties: { foo: { type: 'string' } }
|
|
547
|
-
}, undefined)
|
|
548
|
-
);
|
|
549
|
-
t.false(
|
|
550
|
-
isEnumControl(t.context.uischema, {
|
|
551
|
-
type: 'object',
|
|
552
|
-
properties: {
|
|
553
|
-
foo: {
|
|
554
|
-
type: 'string'
|
|
555
|
-
},
|
|
556
|
-
bar: {
|
|
557
|
-
type: 'string',
|
|
558
|
-
enum: ['a', 'b']
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}, undefined)
|
|
562
|
-
);
|
|
563
|
-
t.true(
|
|
564
|
-
isEnumControl(t.context.uischema, {
|
|
565
|
-
type: 'object',
|
|
566
|
-
properties: { foo: { type: 'string', enum: ['a', 'b'] } }
|
|
567
|
-
}, undefined)
|
|
568
|
-
);
|
|
569
|
-
t.true(
|
|
570
|
-
isEnumControl(t.context.uischema, {
|
|
571
|
-
type: 'object',
|
|
572
|
-
properties: { foo: { type: 'number', enum: [1, 2] } }
|
|
573
|
-
}, undefined)
|
|
574
|
-
);
|
|
575
|
-
t.true(
|
|
576
|
-
isEnumControl(t.context.uischema, {
|
|
577
|
-
type: 'object',
|
|
578
|
-
properties: { foo: { const: '1.0' } }
|
|
579
|
-
}, undefined)
|
|
580
|
-
);
|
|
581
|
-
});
|
|
582
|
-
test('test isIntegerControl', t => {
|
|
583
|
-
t.false(isIntegerControl(undefined, undefined, undefined));
|
|
584
|
-
t.false(isIntegerControl(null, undefined, undefined));
|
|
585
|
-
t.false(isIntegerControl({ type: 'Foo' }, undefined, undefined));
|
|
586
|
-
t.false(isIntegerControl({ type: 'Control' }, undefined, undefined));
|
|
587
|
-
t.false(
|
|
588
|
-
isIntegerControl(t.context.uischema, {
|
|
589
|
-
type: 'object',
|
|
590
|
-
properties: { foo: { type: 'string' } }
|
|
591
|
-
}, undefined)
|
|
592
|
-
);
|
|
593
|
-
t.false(
|
|
594
|
-
isIntegerControl(t.context.uischema, {
|
|
595
|
-
type: 'object',
|
|
596
|
-
properties: { foo: { type: 'string' }, bar: { type: 'integer' } }
|
|
597
|
-
}, undefined)
|
|
598
|
-
);
|
|
599
|
-
t.true(
|
|
600
|
-
isIntegerControl(t.context.uischema, {
|
|
601
|
-
type: 'object',
|
|
602
|
-
properties: { foo: { type: 'integer' } }
|
|
603
|
-
}, undefined)
|
|
604
|
-
);
|
|
605
|
-
});
|
|
606
|
-
test('test isNumberControl', t => {
|
|
607
|
-
t.false(isNumberControl(undefined, undefined, undefined));
|
|
608
|
-
t.false(isNumberControl(null, undefined, undefined));
|
|
609
|
-
t.false(isNumberControl({ type: 'Foo' }, undefined, undefined));
|
|
610
|
-
t.false(isNumberControl({ type: 'Control' }, undefined, undefined));
|
|
611
|
-
t.false(
|
|
612
|
-
isNumberControl(t.context.uischema, {
|
|
613
|
-
type: 'object',
|
|
614
|
-
properties: { foo: { type: 'string' } }
|
|
615
|
-
}, undefined)
|
|
616
|
-
);
|
|
617
|
-
t.false(
|
|
618
|
-
isNumberControl(t.context.uischema, {
|
|
619
|
-
type: 'object',
|
|
620
|
-
properties: { foo: { type: 'string' }, bar: { type: 'number' } }
|
|
621
|
-
}, undefined)
|
|
622
|
-
);
|
|
623
|
-
t.true(
|
|
624
|
-
isNumberControl(t.context.uischema, {
|
|
625
|
-
type: 'object',
|
|
626
|
-
properties: { foo: { type: 'number' } }
|
|
627
|
-
}, undefined)
|
|
628
|
-
);
|
|
629
|
-
});
|
|
630
|
-
test('tester isStringControl', t => {
|
|
631
|
-
t.false(isStringControl(undefined, undefined, undefined));
|
|
632
|
-
t.false(isStringControl(null, undefined, undefined));
|
|
633
|
-
t.false(isStringControl({ type: 'Foo' }, undefined, undefined));
|
|
634
|
-
t.false(isStringControl({ type: 'Control' }, undefined, undefined));
|
|
635
|
-
t.false(
|
|
636
|
-
isStringControl(t.context.uischema, {
|
|
637
|
-
type: 'object',
|
|
638
|
-
properties: { foo: { type: 'number' } }
|
|
639
|
-
}, undefined)
|
|
640
|
-
);
|
|
641
|
-
t.false(
|
|
642
|
-
isStringControl(t.context.uischema, {
|
|
643
|
-
type: 'object',
|
|
644
|
-
properties: { foo: { type: 'number' }, bar: { type: 'string' } }
|
|
645
|
-
}, undefined)
|
|
646
|
-
);
|
|
647
|
-
t.true(
|
|
648
|
-
isStringControl(t.context.uischema, {
|
|
649
|
-
type: 'object',
|
|
650
|
-
properties: { foo: { type: 'string' } }
|
|
651
|
-
}, undefined)
|
|
652
|
-
);
|
|
653
|
-
});
|
|
654
|
-
test('test isTimeControl', t => {
|
|
655
|
-
t.false(isTimeControl(undefined, undefined, undefined));
|
|
656
|
-
t.false(isTimeControl(null, undefined, undefined));
|
|
657
|
-
t.false(isTimeControl({ type: 'Foo' }, undefined, undefined));
|
|
658
|
-
t.false(isTimeControl({ type: 'Control' }, undefined, undefined));
|
|
659
|
-
t.false(
|
|
660
|
-
isTimeControl(t.context.uischema, {
|
|
661
|
-
type: 'object',
|
|
662
|
-
properties: { foo: { type: 'string' } }
|
|
663
|
-
}, undefined)
|
|
664
|
-
);
|
|
665
|
-
t.false(
|
|
666
|
-
isTimeControl(t.context.uischema, {
|
|
667
|
-
type: 'object',
|
|
668
|
-
properties: {
|
|
669
|
-
foo: { type: 'string' },
|
|
670
|
-
bar: { type: 'string', format: 'time' }
|
|
671
|
-
}
|
|
672
|
-
}, undefined)
|
|
673
|
-
);
|
|
674
|
-
t.true(
|
|
675
|
-
isTimeControl(t.context.uischema, {
|
|
676
|
-
type: 'object',
|
|
677
|
-
properties: { foo: { type: 'string', format: 'time' } }
|
|
678
|
-
}, undefined)
|
|
679
|
-
);
|
|
680
|
-
});
|
|
681
|
-
test('tester isMultiLineControl', t => {
|
|
682
|
-
t.false(isMultiLineControl(undefined, undefined, undefined));
|
|
683
|
-
t.false(isMultiLineControl(null, undefined, undefined));
|
|
684
|
-
t.false(isMultiLineControl({ type: 'Foo' }, undefined, undefined));
|
|
685
|
-
t.false(isMultiLineControl({ type: 'Control' }, undefined, undefined));
|
|
686
|
-
t.false(
|
|
687
|
-
isMultiLineControl(t.context.uischema, {
|
|
688
|
-
type: 'object',
|
|
689
|
-
properties: { foo: { type: 'string' } }
|
|
690
|
-
}, undefined)
|
|
691
|
-
);
|
|
692
|
-
const control = t.context.uischema;
|
|
693
|
-
control.options = { multi: true };
|
|
694
|
-
t.true(
|
|
695
|
-
isMultiLineControl(control, {
|
|
696
|
-
type: 'object',
|
|
697
|
-
properties: { foo: { type: 'string' } }
|
|
698
|
-
}, undefined)
|
|
699
|
-
);
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
test('tester isObjectArrayWithNesting', t => {
|
|
703
|
-
const schema = {
|
|
704
|
-
type: 'array',
|
|
705
|
-
items: {
|
|
706
|
-
type: 'object',
|
|
707
|
-
properties: {
|
|
708
|
-
message: {
|
|
709
|
-
type: 'string',
|
|
710
|
-
maxLength: 3
|
|
711
|
-
},
|
|
712
|
-
done: {
|
|
713
|
-
type: 'boolean'
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
const nestedSchema = {
|
|
720
|
-
type: 'array',
|
|
721
|
-
items: {
|
|
722
|
-
...schema
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
const uischema = {
|
|
727
|
-
type: 'Control',
|
|
728
|
-
scope: '#'
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
const nestedSchema2 = {
|
|
732
|
-
type: 'array',
|
|
733
|
-
items: {
|
|
734
|
-
type: 'object',
|
|
735
|
-
properties: {
|
|
736
|
-
objectarrayofstrings: {
|
|
737
|
-
type: 'object',
|
|
738
|
-
properties: {
|
|
739
|
-
choices: {
|
|
740
|
-
type: 'array',
|
|
741
|
-
items: {
|
|
742
|
-
type: 'string'
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
const nestedSchema3 = {
|
|
751
|
-
type: 'array',
|
|
752
|
-
items: {
|
|
753
|
-
type: 'object',
|
|
754
|
-
properties: {
|
|
755
|
-
Level2: {
|
|
756
|
-
type: 'object',
|
|
757
|
-
properties: {
|
|
758
|
-
Level3: {
|
|
759
|
-
type: 'string'
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
const nestedSchemaWithRef =
|
|
768
|
-
{
|
|
769
|
-
definitions: { itemsType: { ...schema } },
|
|
770
|
-
type: 'array',
|
|
771
|
-
items: {
|
|
772
|
-
$ref: '#/definitions/itemsType'
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
const nestedSchemaWithAnyOf = {
|
|
777
|
-
type: "array",
|
|
778
|
-
items: {
|
|
779
|
-
anyOf: [
|
|
780
|
-
{
|
|
781
|
-
type: "object",
|
|
782
|
-
properties: {
|
|
783
|
-
value: {
|
|
784
|
-
type: "string"
|
|
785
|
-
}
|
|
786
|
-
},
|
|
787
|
-
required: ["value"]
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
type: "object",
|
|
791
|
-
properties: {
|
|
792
|
-
value: {
|
|
793
|
-
type: "number"
|
|
794
|
-
}
|
|
795
|
-
},
|
|
796
|
-
required: ["value"]
|
|
797
|
-
}
|
|
798
|
-
]
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
|
|
802
|
-
const nestedSchemaWithOneOf = {
|
|
803
|
-
type: "array",
|
|
804
|
-
items: {
|
|
805
|
-
oneOf: [
|
|
806
|
-
{
|
|
807
|
-
type: "object",
|
|
808
|
-
properties: {
|
|
809
|
-
value: {
|
|
810
|
-
type: "string"
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
required: ["value"]
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
type: "object",
|
|
817
|
-
properties: {
|
|
818
|
-
value: {
|
|
819
|
-
type: "number"
|
|
820
|
-
}
|
|
821
|
-
},
|
|
822
|
-
required: ["value"]
|
|
823
|
-
}
|
|
824
|
-
]
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
|
|
828
|
-
const uischemaOptions: {
|
|
829
|
-
generate: ControlElement;
|
|
830
|
-
default: ControlElement;
|
|
831
|
-
inline: ControlElement;
|
|
832
|
-
} = {
|
|
833
|
-
default: {
|
|
834
|
-
type: 'Control',
|
|
835
|
-
scope: '#',
|
|
836
|
-
options: {
|
|
837
|
-
detail: 'DEFAULT'
|
|
838
|
-
}
|
|
839
|
-
},
|
|
840
|
-
generate: {
|
|
841
|
-
type: 'Control',
|
|
842
|
-
scope: '#',
|
|
843
|
-
options: {
|
|
844
|
-
detail: 'GENERATE'
|
|
845
|
-
}
|
|
846
|
-
},
|
|
847
|
-
inline: {
|
|
848
|
-
type: 'Control',
|
|
849
|
-
scope: '#',
|
|
850
|
-
options: {
|
|
851
|
-
detail: {
|
|
852
|
-
type: 'HorizontalLayout',
|
|
853
|
-
elements: [
|
|
854
|
-
{
|
|
855
|
-
type: 'Control',
|
|
856
|
-
scope: '#/properties/message'
|
|
857
|
-
}
|
|
858
|
-
]
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
t.false(isObjectArrayWithNesting(undefined, undefined, undefined));
|
|
865
|
-
t.false(isObjectArrayWithNesting(null, undefined, undefined));
|
|
866
|
-
t.false(isObjectArrayWithNesting({ type: 'Foo' }, undefined, undefined));
|
|
867
|
-
t.false(isObjectArrayWithNesting({ type: 'Control' }, undefined, undefined));
|
|
868
|
-
t.false(isObjectArrayWithNesting(uischema, schema, undefined));
|
|
869
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema, undefined));
|
|
870
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema2, undefined));
|
|
871
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchema3, undefined));
|
|
872
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithRef, createTesterContext(nestedSchemaWithRef)));
|
|
873
|
-
|
|
874
|
-
t.false(isObjectArrayWithNesting(uischemaOptions.default, schema, undefined));
|
|
875
|
-
t.true(isObjectArrayWithNesting(uischemaOptions.generate, schema, undefined));
|
|
876
|
-
t.true(isObjectArrayWithNesting(uischemaOptions.inline, schema, undefined));
|
|
877
|
-
|
|
878
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithAnyOf, undefined));
|
|
879
|
-
t.true(isObjectArrayWithNesting(uischema, nestedSchemaWithOneOf, undefined));
|
|
880
|
-
});
|
|
881
|
-
|
|
882
|
-
test('tester schemaSubPathMatches', t => {
|
|
883
|
-
const schema = {
|
|
884
|
-
title: 'Things',
|
|
885
|
-
type: 'array',
|
|
886
|
-
items: {
|
|
887
|
-
type: 'number'
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
const uischema: ControlElement = {
|
|
891
|
-
type: 'Control',
|
|
892
|
-
scope: '#'
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
t.true(
|
|
896
|
-
schemaSubPathMatches('items', items => items.type === 'number')(
|
|
897
|
-
uischema,
|
|
898
|
-
schema,
|
|
899
|
-
undefined
|
|
900
|
-
)
|
|
901
|
-
);
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
test('tester not', t => {
|
|
905
|
-
t.false(
|
|
906
|
-
not(isBooleanControl)(t.context.uischema, {
|
|
907
|
-
type: 'boolean'
|
|
908
|
-
}, undefined)
|
|
909
|
-
);
|
|
910
|
-
});
|
|
911
|
-
|
|
912
|
-
test('tester isOneOfEnumControl', t => {
|
|
913
|
-
const control: ControlElement = {
|
|
914
|
-
type: 'Control',
|
|
915
|
-
scope: '#/properties/country'
|
|
916
|
-
};
|
|
917
|
-
const oneOfSchema = {
|
|
918
|
-
type: 'string',
|
|
919
|
-
oneOf: [
|
|
920
|
-
{
|
|
921
|
-
const: 'AU',
|
|
922
|
-
title: 'Australia'
|
|
923
|
-
},
|
|
924
|
-
{
|
|
925
|
-
const: 'NZ',
|
|
926
|
-
title: 'New Zealand'
|
|
927
|
-
}
|
|
928
|
-
]
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
t.true(isOneOfEnumControl(control, {
|
|
932
|
-
type: 'object',
|
|
933
|
-
properties: {
|
|
934
|
-
country: oneOfSchema
|
|
935
|
-
}
|
|
936
|
-
}, undefined));
|
|
937
|
-
const schemaWithRefs = {
|
|
938
|
-
definitions: { country: oneOfSchema },
|
|
939
|
-
type: 'object',
|
|
940
|
-
properties: {
|
|
941
|
-
country: {
|
|
942
|
-
$ref: '#/definitions/country'
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
const testerContext = createTesterContext(schemaWithRefs);
|
|
947
|
-
t.true(isOneOfEnumControl(control, schemaWithRefs, testerContext));
|
|
948
|
-
});
|