File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1316,6 +1316,23 @@ describe("getTemplate", () => {
1316
1316
expect ( res ) . to . deep . equal ( [ "one" ] ) ;
1317
1317
} ) ;
1318
1318
1319
+ it ( "should add items to default-array with 'extendDefaults:true'" , ( ) => {
1320
+ draft . setSchema ( {
1321
+ type : "array" ,
1322
+ default : [ ] ,
1323
+ items : {
1324
+ type : "string" ,
1325
+ enum : [ "one" , "two" ]
1326
+ } ,
1327
+ minItems : 1 // usually adds an enty, but default states: []
1328
+ } ) ;
1329
+ const res = getTemplate ( draft , undefined , draft . getSchema ( ) , {
1330
+ extendDefaults : true
1331
+ } ) ;
1332
+
1333
+ expect ( res ) . to . deep . equal ( [ "one" ] ) ;
1334
+ } ) ;
1335
+
1319
1336
it ( "should not add required items to object with default-value given and 'extendDefaults:false'" , ( ) => {
1320
1337
draft . setSchema ( {
1321
1338
type : "object" ,
@@ -1344,6 +1361,21 @@ describe("getTemplate", () => {
1344
1361
extendDefaults : false
1345
1362
} ) ;
1346
1363
1364
+ expect ( res ) . to . deep . equal ( { title : "" } ) ;
1365
+ } ) ;
1366
+ it ( "should extend default-object with 'extendDefaults:true'" , ( ) => {
1367
+ draft . setSchema ( {
1368
+ type : "object" ,
1369
+ required : [ "title" ] ,
1370
+ default : { } ,
1371
+ properties : {
1372
+ title : { type : "string" }
1373
+ }
1374
+ } ) ;
1375
+ const res = getTemplate ( draft , undefined , draft . getSchema ( ) , {
1376
+ extendDefaults : true
1377
+ } ) ;
1378
+
1347
1379
expect ( res ) . to . deep . equal ( { title : "" } ) ;
1348
1380
} ) ;
1349
1381
} ) ;
You can’t perform that action at this time.
0 commit comments