No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

search-placeholder-tests.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. module('Selection containers - Inline search - Placeholder');
  2. var MultipleSelection = require('select2/selection/multiple');
  3. var InlineSearch = require('select2/selection/search');
  4. var SelectionPlaceholder = require('select2/selection/placeholder');
  5. var $ = require('jquery');
  6. var Options = require('select2/options');
  7. var Utils = require('select2/utils');
  8. var CustomSelection = Utils.Decorate(
  9. Utils.Decorate(MultipleSelection, SelectionPlaceholder),
  10. InlineSearch
  11. );
  12. test('width does not extend the search box', function (assert) {
  13. assert.expect(2);
  14. var $container = $(
  15. '<div style="width: 100px; display: table-cell">' +
  16. '<div style="width: 100%" ' +
  17. 'class="select2-container select2-container--default"></div>' +
  18. '</div>'
  19. );
  20. var container = new MockContainer();
  21. var $element = $('#qunit-fixture .multiple');
  22. var selection = new CustomSelection($element, new Options({
  23. placeholder: 'Test placeholder'
  24. }));
  25. var $selection = selection.render();
  26. selection.bind(container, $container);
  27. // Make it visible so the browser can place focus on the search
  28. $container.append($selection);
  29. $('#qunit-fixture').append($container);
  30. // Update the selection so the search is rendered
  31. selection.update([]);
  32. var $search = $selection.find('input');
  33. assert.equal(
  34. $search.outerWidth(),
  35. 60,
  36. 'The search should not be the entire width of the container'
  37. );
  38. assert.equal(
  39. $container.children().outerWidth(),
  40. 100,
  41. 'The container should be the width assigned to the parent in CSS'
  42. );
  43. });