File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -455,3 +455,35 @@ test('data objects use the text of the option', function (assert) {
455455 assert . equal ( item . id , '&' ) ;
456456 assert . equal ( item . text , '&' ) ;
457457} ) ;
458+
459+ test ( 'select option construction accepts id=0 (zero) value' , function ( assert ) {
460+ var $select = $ ( '#qunit-fixture .single' ) ;
461+
462+ var selectOptions = [ { id : 0 , text : 'Zero Value' } ] ;
463+ var data = new SelectData ( $select , selectOptions ) ;
464+
465+ var optionElem = data . option ( selectOptions [ 0 ] ) ;
466+
467+ // If was "Zero Value"", then it ignored id property
468+ assert . equal (
469+ optionElem [ 0 ] . value ,
470+ '0' ,
471+ 'Built option value should be "0" (zero as a string).'
472+ ) ;
473+ } ) ;
474+
475+ test ( 'select option construction accepts id="" (empty string) value' ,
476+ function ( assert ) {
477+ var $select = $ ( '#qunit-fixture .single' ) ;
478+
479+ var selectOptions = [ { id : '' , text : 'Empty String' } ] ;
480+ var data = new SelectData ( $select , selectOptions ) ;
481+
482+ var optionElem = data . option ( selectOptions [ 0 ] ) ;
483+
484+ assert . equal (
485+ optionElem [ 0 ] . value ,
486+ '' ,
487+ 'Built option value should be an empty string.'
488+ ) ;
489+ } ) ;
You can’t perform that action at this time.
0 commit comments