Skip to content

Commit 0358ee5

Browse files
committed
Added two test cases (zero and empty string check)
This adds two test cases for 16b4840.
1 parent 16b4840 commit 0358ee5

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/data/select-tests.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
});

0 commit comments

Comments
 (0)