Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('more than one default option can be changed via set()', function(assert) {
var defaults = require('select2/defaults');
var ajaxDelay = 123;
var dataDataType = 'xml';
defaults.set('ajax--delay', ajaxDelay);
defaults.set('ajax--data-type', dataDataType);
assert.equal(
defaults.defaults.ajax.delay,
ajaxDelay,
'Both ajax.delay and ajax.dataType present in defaults');
assert.equal(
defaults.defaults.ajax.dataType,
dataDataType,
'Both ajax.delay and ajax.dataType present in defaults');
defaults.reset();
});
test('options are merged recursively with default options', function (assert) {
var defaults = require('select2/defaults');
var ajaxDelay = 250;
var ajaxUrl = 'http://www.test.com';
var mergedOptions;
defaults.set('ajax--delay', ajaxDelay);
mergedOptions = defaults.apply({
ajax: {
url: ajaxUrl
}
});
assert.equal(
mergedOptions.ajax.delay,
ajaxDelay,
'Ajax default options are present on the merged options'
);
assert.equal(
mergedOptions.ajax.url,
ajaxUrl,
test('more than one default option can be changed via set()', function(assert) {
var defaults = require('select2/defaults');
var ajaxDelay = 123;
var dataDataType = 'xml';
defaults.set('ajax--delay', ajaxDelay);
defaults.set('ajax--data-type', dataDataType);
assert.equal(
defaults.defaults.ajax.delay,
ajaxDelay,
'Both ajax.delay and ajax.dataType present in defaults');
assert.equal(
defaults.defaults.ajax.dataType,
dataDataType,
'Both ajax.delay and ajax.dataType present in defaults');
defaults.reset();
});
test('lang attr overrides default language', function (assert) {
var $element = $('<select lang="it"></select>');
Defaults.set('language', 'es');
var options = new Options({}, $element);
assert.deepEqual(
options.get('language'),
['it', 'es', 'en']
);
});
test('partial dictionaries can be combined with defaults', function (assert) {
var $element = $('<select></select>');
Defaults.set('language', {
test: function () {
return 'Testing';
}
});
var options = new Options({
language: {
searching: function () {
return 'Something';
}
}
}, $element);
var translations = options.get('translations');
assert.equal(