QUnit.module('Utils - RemoveData'); var $ = require('jquery'); var Utils = require('select2/utils'); QUnit.test('The data-select2-id attribute is removed', function (assert) { var $element = $(''); 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) { var $element = $(''); 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) { assert.expect(0); var $element = $(''); Utils.RemoveData($element[0]); });