1
0
mirror of synced 2024-11-29 08:06:03 +03:00
select2/tests/utils/data-tests.js

36 lines
951 B
JavaScript
Raw Permalink Normal View History

QUnit.module('Utils - RemoveData');
2019-08-08 04:25:01 +03:00
var $ = require('jquery');
var Utils = require('select2/utils');
QUnit.test('The data-select2-id attribute is removed', function (assert) {
2019-08-08 04:25:01 +03:00
var $element = $('<select data-select2-id="test"></select>');
Utils.RemoveData($element[0]);
assert.notEqual(
$element.attr('data-select2-id'),
'test',
'The internal attribute was not removed when the data was cleared'
);
});
QUnit.test('The internal cache for the element is cleared', function (assert) {
2019-08-08 04:25:01 +03:00
var $element = $('<select data-select2-id="test"></select>');
Utils.__cache.test = {
'foo': 'bar'
};
Utils.RemoveData($element[0]);
assert.equal(Utils.__cache.test, null, 'The cache should now be empty');
});
QUnit.test('Calling it on an element without data works', function (assert) {
2019-08-08 04:25:01 +03:00
assert.expect(0);
var $element = $('<select></select>');
Utils.RemoveData($element[0]);
});