Sha256: daad338b9d181c3e29a5c457d29bff3eebfd3c3e2a15cefc0d2fee1bb87f51e7

Contents?: true

Size: 1.41 KB

Versions: 13

Compression:

Stored size: 1.41 KB

Contents

var $ = require('jquery');
var Utils = require('select2/utils');

module('Utils - GetUniqueElementId');

test('Adds a prefix to the existing ID if one exists', function (assert) {
    var $element = $('<select id="existing-id"></select>');

    var id = Utils.GetUniqueElementId($element[0]);

    assert.notEqual(id, 'existing-id');
    assert.notEqual(id.indexOf('existing-id'), -1);
});

test('Generated random ID is not a number', function (assert) {
    var $element = $('<select></select>');

    var id = Utils.GetUniqueElementId($element[0]);

    assert.ok(isNaN(id));
});

module('Utils - RemoveData');

test('The data-select2-id attribute is removed', function (assert) {
    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'
    );
});

test('The internal cache for the element is cleared', function (assert) {
    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');
});

test('Calling it on an element without data works', function (assert) {
    assert.expect(0);

    var $element = $('<select></select>');

    Utils.RemoveData($element[0]);
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.18.1 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.18.0 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.17.0 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.16.0 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.6 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.5 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.4 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.3 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.1.2 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.2.pre1 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.1.1 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.1 vendor/select2/tests/utils/data-tests.js
card-mod-bootstrap-0.15.0 vendor/select2/tests/utils/data-tests.js