test('single value matches jquery value', function (assert) { var $select = $( '<select>' + '<option>One</option>' + '<option>Two</option>' + '<option value="3" selected>Three</option>' + '</select>' ); var options = new Options({}); var select = new Select2($select, options); var value = select.val(); assert.equal( value, '3', 'The value should match the option tag attribute' ); assert.equal( value, $select.val(), 'The value should match the jquery value' ); });
test('multiple value matches the jquery value', function (assert) { var $select = $( '<select multiple>' + '<option selected>One</option>' + '<option>Two</option>' + '<option value="3" selected>Three</option>' + '</select>' ); var options = new Options({}); var select = new Select2($select, options); var value = select.val(); assert.equal( value.length, 2, 'Two options should be selected' ); assert.deepEqual( value, ['One', '3'], 'The values should match the option tag attribute' ); assert.deepEqual( value, $select.val(), 'The values should match the jquery values' ); });