File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -278,12 +278,16 @@ export function orderProperties(properties, order) {
278278}
279279
280280export function isMultiSelect ( schema ) {
281- return Array . isArray ( schema . items . enum ) && schema . uniqueItems ;
281+ return schema . items
282+ ? Array . isArray ( schema . items . enum ) && schema . uniqueItems
283+ : false ;
282284}
283285
284286export function isFilesArray ( schema , uiSchema ) {
285287 return (
286- ( schema . items . type === "string" && schema . items . format === "data-url" ) ||
288+ ( schema . items &&
289+ schema . items . type === "string" &&
290+ schema . items . format === "data-url" ) ||
287291 uiSchema [ "ui:widget" ] === "files"
288292 ) ;
289293}
Original file line number Diff line number Diff line change 55 dataURItoBlob ,
66 deepEquals ,
77 getDefaultFormState ,
8+ isFilesArray ,
89 isMultiSelect ,
910 mergeObjects ,
1011 pad ,
@@ -274,6 +275,11 @@ describe("utils", () => {
274275 expect ( isMultiSelect ( schema ) ) . to . be . true ;
275276 } ) ;
276277
278+ it ( "should be false if items is undefined" , ( ) => {
279+ const schema = { } ;
280+ expect ( isMultiSelect ( schema ) ) . to . be . false ;
281+ } ) ;
282+
277283 it ( "should be false if uniqueItems is false" , ( ) => {
278284 const schema = { items : { enum : [ "foo" , "bar" ] } , uniqueItems : false } ;
279285 expect ( isMultiSelect ( schema ) ) . to . be . false ;
@@ -285,6 +291,20 @@ describe("utils", () => {
285291 } ) ;
286292 } ) ;
287293
294+ describe ( "isFilesArray()" , ( ) => {
295+ it ( "should be true if items have data-url format" , ( ) => {
296+ const schema = { items : { type : "string" , format : "data-url" } } ;
297+ const uiSchema = { } ;
298+ expect ( isFilesArray ( schema , uiSchema ) ) . to . be . true ;
299+ } ) ;
300+
301+ it ( "should be false if items is undefined" , ( ) => {
302+ const schema = { } ;
303+ const uiSchema = { } ;
304+ expect ( isFilesArray ( schema , uiSchema ) ) . to . be . false ;
305+ } ) ;
306+ } ) ;
307+
288308 describe ( "mergeObjects()" , ( ) => {
289309 it ( "should't mutate the provided objects" , ( ) => {
290310 const obj1 = { a : 1 } ;
You can’t perform that action at this time.
0 commit comments