1
0
mirror of synced 2025-02-03 21:59:24 +03:00

Add failing test for existing array selections

This adds a broken test that demonstrates the issue seen in
https://github.com/select2/select2/issues/3990 where existing selected
options are being reset once Select2 is initialized. This issue cannot
be reproduced on the options page [1] because the issue only appear to
happen if the selected option is not the first one in the list of
possible options.

[1]: https://select2.github.io/examples.html#data-array
This commit is contained in:
Kevin Brown 2016-01-03 18:21:09 -05:00
parent f58c1efc11
commit d1ed0a513a

View File

@ -288,3 +288,31 @@ test('optgroup tags have the right properties', function (assert) {
'The <optgroup> should have one child under it'
);
});
test('existing selections are respected on initialization', function (assert) {
var $select = $(
'<select>' +
'<option>First</option>' +
'<option selected>Second</option>' +
'</select>'
);
var options = new Options({
data: [
{
id: 'Second',
text: 'Second'
},
{
id: 'Third',
text: 'Third'
}
]
});
assert.equal($select.val(), 'Second');
var data = new ArrayData($select, options);
assert.equal($select.val(), 'Second');
});