File tree Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -868,7 +868,8 @@ const mapStateToCombinatorRendererProps = (
868
868
'required' ,
869
869
'additionalProperties' ,
870
870
'type' ,
871
- 'enum'
871
+ 'enum' ,
872
+ 'const'
872
873
] ;
873
874
const dataIsValid = ( errors : ErrorObject [ ] ) : boolean => {
874
875
return (
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ import {
51
51
JsonFormsCore ,
52
52
JsonFormsState ,
53
53
JsonSchema ,
54
+ JsonSchema7 ,
55
+ mapStateToAnyOfProps ,
56
+ OwnPropsOfControl ,
54
57
rankWith ,
55
58
RuleEffect ,
56
59
UISchemaElement
@@ -1218,3 +1221,59 @@ test('computeLabel - should add asterisk if required but hideRequiredAsterisk is
1218
1221
const computedLabel = computeLabel ( 'Test Label' , true , false ) ;
1219
1222
t . is ( computedLabel , 'Test Label*' ) ;
1220
1223
} ) ;
1224
+
1225
+ test ( 'mapStateToAnyOfProps - const constraint in anyOf schema should return correct indexOfFittingSchema' , t => {
1226
+ const uischema : ControlElement = {
1227
+ type : 'Control' ,
1228
+ scope : '#'
1229
+ } ;
1230
+ const schema : JsonSchema7 = {
1231
+ anyOf : [
1232
+ {
1233
+ type : "object" ,
1234
+ properties : {
1235
+ type : {
1236
+ const : "type1"
1237
+ }
1238
+ }
1239
+ } ,
1240
+ {
1241
+ type : "object" ,
1242
+ properties : {
1243
+ type : {
1244
+ const : "type2"
1245
+ }
1246
+ }
1247
+ } ,
1248
+ {
1249
+ type : "object" ,
1250
+ properties : {
1251
+ type : {
1252
+ const : "type3"
1253
+ }
1254
+ }
1255
+ }
1256
+ ]
1257
+ } ;
1258
+ const ownProps : OwnPropsOfControl = {
1259
+ visible : true ,
1260
+ uischema,
1261
+ path : 'foo'
1262
+ } ;
1263
+ const state = {
1264
+ jsonforms : {
1265
+ core : {
1266
+ ajv : createAjv ( ) ,
1267
+ schema,
1268
+ data : {
1269
+ foo : { type : "type3" }
1270
+ } ,
1271
+ uischema,
1272
+ errors : [ ] as ErrorObject [ ]
1273
+ }
1274
+ }
1275
+ } ;
1276
+ const props = mapStateToAnyOfProps ( state , ownProps ) ;
1277
+ console . log ( JSON . stringify ( props , null , 2 ) ) ;
1278
+ t . is ( props . indexOfFittingSchema , 2 ) ;
1279
+ } ) ;
You can’t perform that action at this time.
0 commit comments