Explorar o código

Added tests for jQuery calls to Select2

This adds a test that covers the change made in
c2c1aeef31c95c6df5545c900a4e1782d712497c.
Kevin Brown %!s(int64=9) %!d(string=hai) anos
pai
achega
ac254ff68d
Modificáronse 2 ficheiros con 29 adicións e 0 borrados
  1. 1 0
      tests/integration.html
  2. 28 0
      tests/integration/jquery-calls.js

+ 1 - 0
tests/integration.html

@@ -14,6 +14,7 @@
 
     <script src="helpers.js" type="text/javascript"></script>
 
+    <script src="integration/jquery-calls.js" type="text/javascript"></script>
     <script src="integration/select2-methods.js" type="text/javascript"></script>
   </body>
 </html>

+ 28 - 0
tests/integration/jquery-calls.js

@@ -0,0 +1,28 @@
+test('multiple elements with arguments works', function (assert) {
+  var $ = require('jquery');
+  require('jquery.select2');
+
+  var $first = $(
+    '<select>' +
+      '<option>1</option>' +
+      '<option>2</option>' +
+    '</select>'
+  );
+  var $second = $first.clone();
+
+  var $both = $first.add($second);
+  $both.select2();
+
+  $both.select2('val', '2');
+
+  assert.equal(
+    $first.val(),
+    '2',
+    'The call should change the value on the first element'
+  );
+  assert.equal(
+    $second.val(),
+    '2',
+    'The call should also change the value on the second element'
+  );
+});