jquery-calls.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. test('multiple elements with arguments works', function (assert) {
  2. var $ = require('jquery');
  3. require('jquery.select2');
  4. var $first = $(
  5. '<select>' +
  6. '<option>1</option>' +
  7. '<option>2</option>' +
  8. '</select>'
  9. );
  10. var $second = $first.clone();
  11. var $both = $first.add($second);
  12. $both.select2();
  13. $both.select2('val', '2');
  14. assert.equal(
  15. $first.val(),
  16. '2',
  17. 'The call should change the value on the first element'
  18. );
  19. assert.equal(
  20. $second.val(),
  21. '2',
  22. 'The call should also change the value on the second element'
  23. );
  24. });
  25. test('initializes correctly when jQuery $.data contains cyclic reference object', function (assert) {
  26. var $ = require('jquery');
  27. require('jquery.select2');
  28. var $select = $(
  29. '<select>' +
  30. '<option>One</option>' +
  31. '<option>Two</option>' +
  32. '<option value="3" selected>Three</option>' +
  33. '</select>'
  34. );
  35. // Add a circular reference object using jQuery.
  36. var recursiveObject = {};
  37. recursiveObject['same'] = recursiveObject;
  38. $select.data('same', recursiveObject);
  39. $select.select2();
  40. assert.equal(
  41. $select.val(),
  42. '3',
  43. 'The option value should be pulled correctly'
  44. );
  45. });