2019-08-08 04:16:45 +03:00
|
|
|
QUnit.module('Utils - RemoveData');
|
2019-08-08 04:25:01 +03:00
|
|
|
|
|
|
|
var $ = require('jquery');
|
|
|
|
var Utils = require('select2/utils');
|
|
|
|
|
2019-08-08 04:16:45 +03:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-08-08 04:16:45 +03:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2019-08-08 04:16:45 +03:00
|
|
|
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]);
|
2019-07-28 04:37:43 +03:00
|
|
|
});
|