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:
parent
f58c1efc11
commit
d1ed0a513a
@ -288,3 +288,31 @@ test('optgroup tags have the right properties', function (assert) {
|
|||||||
'The <optgroup> should have one child under it'
|
'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');
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user