Skip to content

Commit ac254ff

Browse files
committed
Added tests for jQuery calls to Select2
This adds a test that covers the change made in c2c1aee.
1 parent c2c1aee commit ac254ff

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/integration.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<script src="helpers.js" type="text/javascript"></script>
1616

17+
<script src="integration/jquery-calls.js" type="text/javascript"></script>
1718
<script src="integration/select2-methods.js" type="text/javascript"></script>
1819
</body>
1920
</html>

tests/integration/jquery-calls.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
test('multiple elements with arguments works', function (assert) {
2+
var $ = require('jquery');
3+
require('jquery.select2');
4+
5+
var $first = $(
6+
'<select>' +
7+
'<option>1</option>' +
8+
'<option>2</option>' +
9+
'</select>'
10+
);
11+
var $second = $first.clone();
12+
13+
var $both = $first.add($second);
14+
$both.select2();
15+
16+
$both.select2('val', '2');
17+
18+
assert.equal(
19+
$first.val(),
20+
'2',
21+
'The call should change the value on the first element'
22+
);
23+
assert.equal(
24+
$second.val(),
25+
'2',
26+
'The call should also change the value on the second element'
27+
);
28+
});

0 commit comments

Comments
 (0)