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.

data-tests.js 927B

123456789101112131415161718192021222324252627282930313233343536
  1. module('Utils - RemoveData');
  2. var $ = require('jquery');
  3. var Utils = require('select2/utils');
  4. test('The data-select2-id attribute is removed', function (assert) {
  5. var $element = $('<select data-select2-id="test"></select>');
  6. Utils.RemoveData($element[0]);
  7. assert.notEqual(
  8. $element.attr('data-select2-id'),
  9. 'test',
  10. 'The internal attribute was not removed when the data was cleared'
  11. );
  12. });
  13. test('The internal cache for the element is cleared', function (assert) {
  14. var $element = $('<select data-select2-id="test"></select>');
  15. Utils.__cache.test = {
  16. 'foo': 'bar'
  17. };
  18. Utils.RemoveData($element[0]);
  19. assert.equal(Utils.__cache.test, null, 'The cache should now be empty');
  20. });
  21. test('Calling it on an element without data works', function (assert) {
  22. assert.expect(0);
  23. var $element = $('<select></select>');
  24. Utils.RemoveData($element[0]);
  25. });