@@ -291,7 +291,7 @@ describe("NumberField", () => {
291
291
expect ( node . querySelector ( "select" ) . id ) . eql ( "root" ) ;
292
292
} ) ;
293
293
294
- it ( "should render a select element if set the enum ." , ( ) => {
294
+ it ( "should render a select element with a blank option, when default value is not set ." , ( ) => {
295
295
const schema = {
296
296
type : "object" ,
297
297
properties : {
@@ -307,16 +307,21 @@ describe("NumberField", () => {
307
307
} ) ;
308
308
309
309
const selects = node . querySelectorAll ( "select" ) ;
310
- expect ( selects ) . to . have . length . of ( 1 ) ;
310
+ expect ( selects [ 0 ] . value ) . eql ( "" ) ;
311
+
312
+ const options = node . querySelectorAll ( "option" ) ;
313
+ expect ( options . length ) . eql ( 2 ) ;
314
+ expect ( options [ 0 ] . innerHTML ) . eql ( "" ) ;
311
315
} ) ;
312
316
313
- it ( "should render a select element and it's value is empty , if set the enum and the default value is undefined ." , ( ) => {
317
+ it ( "should render a select element without a blank option , if a default value is set ." , ( ) => {
314
318
const schema = {
315
319
type : "object" ,
316
320
properties : {
317
321
foo : {
318
322
type : "number" ,
319
- enum : [ 0 ] ,
323
+ enum : [ 2 ] ,
324
+ default : 2 ,
320
325
} ,
321
326
} ,
322
327
} ;
@@ -326,29 +331,14 @@ describe("NumberField", () => {
326
331
} ) ;
327
332
328
333
const selects = node . querySelectorAll ( "select" ) ;
329
- expect ( selects [ 0 ] . value ) . eql ( "" ) ;
330
- } ) ;
331
-
332
- it ( "should render a select element and it's first option has an empty innerHTML, if set the enum and the default value is undefined." , ( ) => {
333
- const schema = {
334
- type : "object" ,
335
- properties : {
336
- foo : {
337
- type : "number" ,
338
- enum : [ 0 ] ,
339
- } ,
340
- } ,
341
- } ;
342
-
343
- const { node } = createFormComponent ( {
344
- schema,
345
- } ) ;
334
+ expect ( selects [ 0 ] . value ) . eql ( "2" ) ;
346
335
347
336
const options = node . querySelectorAll ( "option" ) ;
348
- expect ( options [ 0 ] . innerHTML ) . eql ( "" ) ;
337
+ expect ( options . length ) . eql ( 1 ) ;
338
+ expect ( options [ 0 ] . innerHTML ) . eql ( "2" ) ;
349
339
} ) ;
350
340
351
- it ( "should render a select element and it's first option is '0' , if set the enum and the default value is 0." , ( ) => {
341
+ it ( "should render a select element without a blank option, if the default value is 0." , ( ) => {
352
342
const schema = {
353
343
type : "object" ,
354
344
properties : {
@@ -364,7 +354,11 @@ describe("NumberField", () => {
364
354
schema,
365
355
} ) ;
366
356
357
+ const selects = node . querySelectorAll ( "select" ) ;
358
+ expect ( selects [ 0 ] . value ) . eql ( "0" ) ;
359
+
367
360
const options = node . querySelectorAll ( "option" ) ;
361
+ expect ( options . length ) . eql ( 1 ) ;
368
362
expect ( options [ 0 ] . innerHTML ) . eql ( "0" ) ;
369
363
} ) ;
370
364
} ) ;
0 commit comments