stopPropagation-tests.js 965 B

12345678910111213141516171819202122232425262728293031323334
  1. module('Selection containers - Stoping event propagation');
  2. var SingleSelection = require('select2/selection/single');
  3. var StopPropagation = require('select2/selection/stopPropagation');
  4. var $ = require('jquery');
  5. var Options = require('select2/options');
  6. var Utils = require('select2/utils');
  7. var CutomSelection = Utils.Decorate(SingleSelection, StopPropagation);
  8. var options = new Options();
  9. test('click event does not propagate', function (assert) {
  10. expect(1);
  11. var $container = $('#qunit-fixture .event-container');
  12. var container = new MockContainer();
  13. var selection = new CutomSelection($('#qunit-fixture select'), options);
  14. var $selection = selection.render();
  15. selection.bind(container, $container);
  16. $container.append($selection);
  17. $container.on('click', function () {
  18. assert.ok(false, 'The click event should have been stopped');
  19. });
  20. $selection.trigger('click');
  21. assert.ok(true, 'Something went wrong if this failed');
  22. });