diff --git a/tests/data/array-tests.js b/tests/data/array-tests.js
index be91aab7..b877d3c7 100644
--- a/tests/data/array-tests.js
+++ b/tests/data/array-tests.js
@@ -259,23 +259,26 @@ QUnit.test('option tags are automatically generated', function (assert) {
);
});
-QUnit.test('automatically generated option tags have a result id', function (assert) {
- var $select = $('#qunit-fixture .single-empty');
+QUnit.test(
+ 'automatically generated option tags have a result id',
+ function (assert) {
+ var $select = $('#qunit-fixture .single-empty');
- var data = new ArrayData($select, arrayOptions);
+ var data = new ArrayData($select, arrayOptions);
- var container = new MockContainer();
- data.bind(container, $('
'));
+ var container = new MockContainer();
+ data.bind(container, $('
'));
- data.select({
- id: 'default'
- });
+ data.select({
+ id: 'default'
+ });
- assert.ok(
- Utils.GetData($select.find(':selected')[0], 'data')._resultId,
- ' default should have a result ID assigned'
- );
-});
+ assert.ok(
+ Utils.GetData($select.find(':selected')[0], 'data')._resultId,
+ ' default should have a result ID assigned'
+ );
+ }
+);
QUnit.test('option tags can receive new data', function(assert) {
var $select = $('#qunit-fixture .single');
@@ -354,9 +357,11 @@ QUnit.test('optgroup tags have the right properties', function (assert) {
);
});
-QUnit.test('existing selections are respected on initialization', function (assert) {
- var $select = $(
- '' +
+QUnit.test(
+ 'existing selections are respected on initialization',
+ function (assert) {
+ var $select = $(
+ '' +
'First ' +
'Second ' +
' '
@@ -383,4 +388,5 @@ QUnit.test('existing selections are respected on initialization', function (asse
data.bind(container, $('
'));
assert.equal($select.val(), 'Second');
-});
\ No newline at end of file
+ }
+);
\ No newline at end of file
diff --git a/tests/data/inputData-tests.js b/tests/data/inputData-tests.js
index 8fb5d477..f4e95588 100644
--- a/tests/data/inputData-tests.js
+++ b/tests/data/inputData-tests.js
@@ -37,33 +37,36 @@ QUnit.test('test that options can be selected', function (assert) {
);
});
-QUnit.test('unselect the single selected option clears the value', function (assert) {
- var options = new Options({
- data: [
- {
- id: 'test',
- text: 'Test',
- selected: true
- }
- ]
- });
- var $element = $(' ');
+QUnit.test(
+ 'unselect the single selected option clears the value',
+ function (assert) {
+ var options = new Options({
+ data: [
+ {
+ id: 'test',
+ text: 'Test',
+ selected: true
+ }
+ ]
+ });
+ var $element = $(' ');
- var adapter = new InputAdapter($element, options);
+ var adapter = new InputAdapter($element, options);
- var container = new MockContainer();
- adapter.bind(container, $('
'));
+ var container = new MockContainer();
+ adapter.bind(container, $('
'));
- adapter.unselect({
- id: 'test'
- });
+ adapter.unselect({
+ id: 'test'
+ });
- assert.equal(
- $element.val(),
- '',
- 'The id should no longer be in the value'
- );
-});
+ assert.equal(
+ $element.val(),
+ '',
+ 'The id should no longer be in the value'
+ );
+ }
+);
QUnit.test('options can be unselected individually', function (assert) {
var options = new Options({
diff --git a/tests/data/select-tests.js b/tests/data/select-tests.js
index 94d8d370..0e054ec0 100644
--- a/tests/data/select-tests.js
+++ b/tests/data/select-tests.js
@@ -417,34 +417,37 @@ QUnit.test('empty optgroups are still shown when queried', function (assert) {
});
});
-QUnit.test('multiple options with the same value are returned', function (assert) {
- var $select = $('#qunit-fixture .duplicates');
+QUnit.test(
+ 'multiple options with the same value are returned',
+ function (assert) {
+ var $select = $('#qunit-fixture .duplicates');
- var data = new SelectData($select, selectOptions);
+ var data = new SelectData($select, selectOptions);
- data.query({}, function (data) {
- assert.equal(
- data.results.length,
- 3,
- 'The duplicate option should still be returned when queried'
- );
+ data.query({}, function (data) {
+ assert.equal(
+ data.results.length,
+ 3,
+ 'The duplicate option should still be returned when queried'
+ );
- var first = data.results[0];
- var duplicate = data.results[2];
+ var first = data.results[0];
+ var duplicate = data.results[2];
- assert.equal(
- first.id,
- duplicate.id,
- 'The duplicates should have the same id'
- );
+ assert.equal(
+ first.id,
+ duplicate.id,
+ 'The duplicates should have the same id'
+ );
- assert.notEqual(
- first.text,
- duplicate.text,
- 'The duplicates do not have the same text'
- );
- });
-});
+ assert.notEqual(
+ first.text,
+ duplicate.text,
+ 'The duplicates do not have the same text'
+ );
+ });
+ }
+);
QUnit.test('data objects use the text of the option', function (assert) {
var $select = $('#qunit-fixture .duplicates');
@@ -459,21 +462,24 @@ QUnit.test('data objects use the text of the option', function (assert) {
assert.equal(item.text, '&');
});
-QUnit.test('select option construction accepts id=0 (zero) value', function (assert) {
- var $select = $('#qunit-fixture .single');
+QUnit.test(
+ 'select option construction accepts id=0 (zero) value',
+ function (assert) {
+ var $select = $('#qunit-fixture .single');
- var selectOptions = [{ id: 0, text: 'Zero Value'}];
- var data = new SelectData($select, selectOptions);
+ var selectOptions = [{ id: 0, text: 'Zero Value'}];
+ var data = new SelectData($select, selectOptions);
- var optionElem = data.option(selectOptions[0]);
+ var optionElem = data.option(selectOptions[0]);
- // If was "Zero Value"", then it ignored id property
- assert.equal(
- optionElem[0].value,
- '0',
- 'Built option value should be "0" (zero as a string).'
- );
-});
+ // If was "Zero Value"", then it ignored id property
+ assert.equal(
+ optionElem[0].value,
+ '0',
+ 'Built option value should be "0" (zero as a string).'
+ );
+ }
+);
QUnit.test('select option construction accepts id="" (empty string) value',
function (assert) {
diff --git a/tests/data/tags-tests.js b/tests/data/tags-tests.js
index ebc2ad5c..d2c4d5bf 100644
--- a/tests/data/tags-tests.js
+++ b/tests/data/tags-tests.js
@@ -64,20 +64,23 @@ QUnit.test('white space is trimmed by default', function (assert) {
});
});
-QUnit.test('does not create option if text is same but lowercase', function (assert) {
- var data = new SelectTags($('#qunit-fixture .single'), options);
+QUnit.test(
+ 'does not create option if text is same but lowercase',
+ function (assert) {
+ var data = new SelectTags($('#qunit-fixture .single'), options);
- data.query({
- term: 'one'
- }, function (data) {
- assert.equal(data.results.length, 1);
+ data.query({
+ term: 'one'
+ }, function (data) {
+ assert.equal(data.results.length, 1);
- var item = data.results[0];
+ var item = data.results[0];
- assert.equal(item.id, 'One');
- assert.equal(item.text, 'One');
- });
-});
+ assert.equal(item.id, 'One');
+ assert.equal(item.text, 'One');
+ });
+ }
+);
QUnit.test('does not trigger for additional pages', function (assert) {
var data = new SelectTags($('#qunit-fixture .single'), options);
@@ -191,25 +194,28 @@ QUnit.test('insertTag controls the tag location', function (assert) {
});
});
-QUnit.test('insertTag can be controlled through the options', function (assert) {
- var options = new Options({
- insertTag: function (data, tag) {
- data.push(tag);
- }
- });
- var data = new SelectTags($('#qunit-fixture .single'), options);
+QUnit.test(
+ 'insertTag can be controlled through the options',
+ function (assert) {
+ var options = new Options({
+ insertTag: function (data, tag) {
+ data.push(tag);
+ }
+ });
+ var data = new SelectTags($('#qunit-fixture .single'), options);
- data.query({
- term: 'o'
- }, function (data) {
- assert.equal(data.results.length, 2);
+ data.query({
+ term: 'o'
+ }, function (data) {
+ assert.equal(data.results.length, 2);
- var item = data.results[1];
+ var item = data.results[1];
- assert.equal(item.id, 'o');
- assert.equal(item.text, 'o');
- });
-});
+ assert.equal(item.id, 'o');
+ assert.equal(item.text, 'o');
+ });
+ }
+);
QUnit.test('createTag controls the tag object', function (assert) {
var data = new SelectTags($('#qunit-fixture .single'), options);
diff --git a/tests/dropdown/positioning-tests.js b/tests/dropdown/positioning-tests.js
index ce8f5ee8..d694364f 100644
--- a/tests/dropdown/positioning-tests.js
+++ b/tests/dropdown/positioning-tests.js
@@ -58,120 +58,126 @@ QUnit.test('appends to the dropdown parent', function (assert) {
);
});
-QUnit.test('dropdown is positioned down with static margins', function (assert) {
- var $ = require('jquery');
- var $select = $(' ');
- var $parent = $('
');
- $parent.css({
- position: 'static',
- marginTop: '5px',
- marginLeft: '10px'
- });
+QUnit.test(
+ 'dropdown is positioned down with static margins',
+ function (assert) {
+ var $ = require('jquery');
+ var $select = $(' ');
+ var $parent = $('
');
+ $parent.css({
+ position: 'static',
+ marginTop: '5px',
+ marginLeft: '10px'
+ });
- var $container = $('test ');
- var container = new MockContainer();
+ var $container = $('test ');
+ var container = new MockContainer();
- $('#qunit-fixture').empty();
+ $('#qunit-fixture').empty();
- $parent.appendTo($('#qunit-fixture'));
- $container.appendTo($parent);
+ $parent.appendTo($('#qunit-fixture'));
+ $container.appendTo($parent);
- var Utils = require('select2/utils');
- var Options = require('select2/options');
+ var Utils = require('select2/utils');
+ var Options = require('select2/options');
- var Dropdown = require('select2/dropdown');
- var AttachBody = require('select2/dropdown/attachBody');
+ var Dropdown = require('select2/dropdown');
+ var AttachBody = require('select2/dropdown/attachBody');
- var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
+ var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
- var dropdown = new DropdownAdapter($select, new Options({
- dropdownParent: $parent
- }));
+ var dropdown = new DropdownAdapter($select, new Options({
+ dropdownParent: $parent
+ }));
- var $dropdown = dropdown.render();
+ var $dropdown = dropdown.render();
- assert.equal(
- $dropdown[0].style.top,
- 0,
- 'The drodpown should not have any offset before it is displayed'
- );
+ assert.equal(
+ $dropdown[0].style.top,
+ 0,
+ 'The drodpown should not have any offset before it is displayed'
+ );
- dropdown.bind(container, $container);
- dropdown.position($dropdown, $container);
- dropdown._showDropdown();
+ dropdown.bind(container, $container);
+ dropdown.position($dropdown, $container);
+ dropdown._showDropdown();
- assert.ok(
- dropdown.$dropdown.hasClass('select2-dropdown--below'),
- 'The dropdown should be forced down'
- );
+ assert.ok(
+ dropdown.$dropdown.hasClass('select2-dropdown--below'),
+ 'The dropdown should be forced down'
+ );
- assert.equal(
- $dropdown.css('top').replace(/\D+/, ''),
- $container.outerHeight() + 5,
- 'The offset should be 5px at the top'
- );
+ assert.equal(
+ $dropdown.css('top').replace(/\D+/, ''),
+ $container.outerHeight() + 5,
+ 'The offset should be 5px at the top'
+ );
- assert.equal(
- $dropdown.css('left'),
- '10px',
- 'The offset should be 10px on the left'
- );
-});
+ assert.equal(
+ $dropdown.css('left'),
+ '10px',
+ 'The offset should be 10px on the left'
+ );
+ }
+);
-QUnit.test('dropdown is positioned down with absolute offsets', function (assert) {
- var $ = require('jquery');
- var $select = $(' ');
- var $parent = $('
');
- $parent.css({
- position: 'absolute',
- top: '10px',
- left: '5px'
- });
+QUnit.test(
+ 'dropdown is positioned down with absolute offsets',
+ function (assert) {
+ var $ = require('jquery');
+ var $select = $(' ');
+ var $parent = $('
');
+ $parent.css({
+ position: 'absolute',
+ top: '10px',
+ left: '5px'
+ });
- var $container = $('test ');
- var container = new MockContainer();
+ var $container = $('test ');
+ var container = new MockContainer();
- $parent.appendTo($('#qunit-fixture'));
- $container.appendTo($parent);
+ $parent.appendTo($('#qunit-fixture'));
+ $container.appendTo($parent);
- var Utils = require('select2/utils');
- var Options = require('select2/options');
+ var Utils = require('select2/utils');
+ var Options = require('select2/options');
- var Dropdown = require('select2/dropdown');
- var AttachBody = require('select2/dropdown/attachBody');
+ var Dropdown = require('select2/dropdown');
+ var AttachBody = require('select2/dropdown/attachBody');
- var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
+ var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
- var dropdown = new DropdownAdapter($select, new Options({
- dropdownParent: $parent
- }));
+ var dropdown = new DropdownAdapter($select, new Options({
+ dropdownParent: $parent
+ }));
- var $dropdown = dropdown.render();
+ var $dropdown = dropdown.render();
- assert.equal(
- $dropdown[0].style.top,
- 0,
- 'The drodpown should not have any offset before it is displayed'
- );
+ assert.equal(
+ $dropdown[0].style.top,
+ 0,
+ 'The drodpown should not have any offset before it is displayed'
+ );
- dropdown.bind(container, $container);
- dropdown.position($dropdown, $container);
- dropdown._showDropdown();
+ dropdown.bind(container, $container);
+ dropdown.position($dropdown, $container);
+ dropdown._showDropdown();
- assert.ok(
- dropdown.$dropdown.hasClass('select2-dropdown--below'),
- 'The dropdown should be forced down'
- );
+ assert.ok(
+ dropdown.$dropdown.hasClass('select2-dropdown--below'),
+ 'The dropdown should be forced down'
+ );
- assert.equal(
- $dropdown.css('top').replace(/\D+/, ''),
- $container.outerHeight(),
- 'There should not be an extra top offset'
- );
+ assert.equal(
+ $dropdown.css('top').replace(/\D+/, ''),
+ $container.outerHeight(),
+ 'There should not be an extra top offset'
+ );
- assert.equal(
- $dropdown.css('left'),
- '0px',
- 'There should not be an extra left offset'
- );
-});
\ No newline at end of file
+ assert.equal(
+ $dropdown.css('left'),
+ '0px',
+ 'There should not be an extra left offset'
+ );
+ }
+);
\ No newline at end of file
diff --git a/tests/dropdown/search-a11y-tests.js b/tests/dropdown/search-a11y-tests.js
index 0f27a0e4..c4bcfc6d 100644
--- a/tests/dropdown/search-a11y-tests.js
+++ b/tests/dropdown/search-a11y-tests.js
@@ -45,88 +45,100 @@ QUnit.test('aria-autocomplete attribute is present', function (assert) {
);
});
-QUnit.test('aria-activedescendant should not be set initiailly', function (assert) {
- var $select = $('#qunit-fixture .single');
+QUnit.test(
+ 'aria-activedescendant should not be set initiailly',
+ function (assert) {
+ var $select = $('#qunit-fixture .single');
- var dropdown = new DropdownSearch($select, options);
- var $dropdown = dropdown.render();
+ var dropdown = new DropdownSearch($select, options);
+ var $dropdown = dropdown.render();
- var container = new MockContainer();
- dropdown.bind(container, $(' '));
+ var container = new MockContainer();
+ dropdown.bind(container, $(' '));
- var $search = $dropdown.find('input');
+ var $search = $dropdown.find('input');
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'The search box should not point to anything when it is first rendered'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'The search box should not point to anything when it is first rendered'
+ );
+ }
+);
-QUnit.test('aria-activedescendant should be set after highlight', function (assert) {
- var $select = $('#qunit-fixture .single');
+QUnit.test(
+ 'aria-activedescendant should be set after highlight',
+ function (assert) {
+ var $select = $('#qunit-fixture .single');
- var dropdown = new DropdownSearch($select, options);
- var $dropdown = dropdown.render();
+ var dropdown = new DropdownSearch($select, options);
+ var $dropdown = dropdown.render();
- var container = new MockContainer();
- dropdown.bind(container, $(' '));
+ var container = new MockContainer();
+ dropdown.bind(container, $(' '));
- container.trigger('results:focus', {
- data: {
- _resultId: 'test'
- }
- });
+ container.trigger('results:focus', {
+ data: {
+ _resultId: 'test'
+ }
+ });
- var $search = $dropdown.find('input');
+ var $search = $dropdown.find('input');
- assert.equal(
- $search.attr('aria-activedescendant'),
- 'test',
- 'The search is pointing to the focused result'
- );
-});
+ assert.equal(
+ $search.attr('aria-activedescendant'),
+ 'test',
+ 'The search is pointing to the focused result'
+ );
+ }
+);
-QUnit.test('activedescendant should remove if there is no ID', function (assert) {
- var $select = $('#qunit-fixture .single');
+QUnit.test(
+ 'activedescendant should remove if there is no ID',
+ function (assert) {
+ var $select = $('#qunit-fixture .single');
- var dropdown = new DropdownSearch($select, options);
- var $dropdown = dropdown.render();
+ var dropdown = new DropdownSearch($select, options);
+ var $dropdown = dropdown.render();
- var container = new MockContainer();
- dropdown.bind(container, $(' '));
+ var container = new MockContainer();
+ dropdown.bind(container, $(' '));
- var $search = $dropdown.find('input');
- $search.attr('aria-activedescendant', 'test');
+ var $search = $dropdown.find('input');
+ $search.attr('aria-activedescendant', 'test');
- container.trigger('results:focus', {
- data: {}
- });
+ container.trigger('results:focus', {
+ data: {}
+ });
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'There is no result for the search to be pointing to'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'There is no result for the search to be pointing to'
+ );
+ }
+);
-QUnit.test('aria-activedescendant should be removed when closed', function (assert) {
- var $select = $('#qunit-fixture .single');
+QUnit.test(
+ 'aria-activedescendant should be removed when closed',
+ function (assert) {
+ var $select = $('#qunit-fixture .single');
- var dropdown = new DropdownSearch($select, options);
- var $dropdown = dropdown.render();
+ var dropdown = new DropdownSearch($select, options);
+ var $dropdown = dropdown.render();
- var container = new MockContainer();
- dropdown.bind(container, $(' '));
+ var container = new MockContainer();
+ dropdown.bind(container, $(' '));
- var $search = $dropdown.find('input');
- $search.attr('aria-activedescendant', 'something');
+ var $search = $dropdown.find('input');
+ $search.attr('aria-activedescendant', 'something');
- container.trigger('close');
+ container.trigger('close');
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'There is no active descendant when the dropdown is closed'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'There is no active descendant when the dropdown is closed'
+ );
+ }
+);
QUnit.test('aria-controls should not be set initiailly', function (assert) {
var $select = $('#qunit-fixture .single');
diff --git a/tests/dropdown/selectOnClose-tests.js b/tests/dropdown/selectOnClose-tests.js
index df4512ac..0aac6257 100644
--- a/tests/dropdown/selectOnClose-tests.js
+++ b/tests/dropdown/selectOnClose-tests.js
@@ -62,44 +62,49 @@ QUnit.test('will not trigger if the results list is empty', function (assert) {
container.trigger('close');
});
-QUnit.test('will not trigger if no results here highlighted', function (assert) {
- assert.expect(2);
+QUnit.test(
+ 'will not trigger if no results here highlighted',
+ function (assert) {
+ assert.expect(2);
- var $element = $(' ');
- var select = new ModifiedResults($element, options, new SelectData($element));
+ var $element = $(' ');
+ var select = new ModifiedResults(
+ $element, options, new SelectData($element)
+ );
- var $dropdown = select.render();
+ var $dropdown = select.render();
- var container = new MockContainer();
- select.bind(container, $('
'));
+ var container = new MockContainer();
+ select.bind(container, $('
'));
- select.on('select', function () {
- assert.ok(false, 'The select event should not have been triggered');
- });
+ select.on('select', function () {
+ assert.ok(false, 'The select event should not have been triggered');
+ });
- select.append({
- results: [
- {
- id: '1',
- text: 'Test'
- }
- ]
- });
+ select.append({
+ results: [
+ {
+ id: '1',
+ text: 'Test'
+ }
+ ]
+ });
- assert.equal(
- $dropdown.find('li').length,
- 1,
- 'There should be one result in the dropdown'
- );
+ assert.equal(
+ $dropdown.find('li').length,
+ 1,
+ 'There should be one result in the dropdown'
+ );
- assert.equal(
- $.trim($dropdown.find('li').text()),
- 'Test',
- 'The result should be the same as the one we appended'
- );
+ assert.equal(
+ $.trim($dropdown.find('li').text()),
+ 'Test',
+ 'The result should be the same as the one we appended'
+ );
- container.trigger('close');
-});
+ container.trigger('close');
+ }
+);
QUnit.test('will trigger if there is a highlighted result', function (assert) {
assert.expect(2);
diff --git a/tests/options/ajax-tests.js b/tests/options/ajax-tests.js
index 70254a96..b396a97e 100644
--- a/tests/options/ajax-tests.js
+++ b/tests/options/ajax-tests.js
@@ -1,50 +1,56 @@
QUnit.module('Defaults - Ajax');
-QUnit.test('options are merged recursively with default options', function (assert) {
- var defaults = require('select2/defaults');
+QUnit.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 ajaxDelay = 250;
+ var ajaxUrl = 'http://www.test.com';
- var mergedOptions;
+ var mergedOptions;
- defaults.set('ajax--delay', ajaxDelay);
+ defaults.set('ajax--delay', ajaxDelay);
- mergedOptions = defaults.apply({
- ajax: {
- url: ajaxUrl
- }
- });
+ 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,
- 'Ajax provided options are present on the merged options'
- );
-
- defaults.reset();
-});
-
-QUnit.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,
+ assert.equal(
+ mergedOptions.ajax.delay,
ajaxDelay,
+ 'Ajax default options are present on the merged options'
+ );
+
+ assert.equal(
+ mergedOptions.ajax.url,
+ ajaxUrl,
+ 'Ajax provided options are present on the merged options'
+ );
+
+ defaults.reset();
+ }
+);
+
+QUnit.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');
- assert.equal(
- defaults.defaults.ajax.dataType,
- dataDataType,
- 'Both ajax.delay and ajax.dataType present in defaults');
- defaults.reset();
-});
+ defaults.reset();
+ }
+);
diff --git a/tests/options/deprecated-tests.js b/tests/options/deprecated-tests.js
index a9433c93..25f485c4 100644
--- a/tests/options/deprecated-tests.js
+++ b/tests/options/deprecated-tests.js
@@ -234,17 +234,20 @@ QUnit.test('converted ajax-url to ajax--url automatically', function (assert) {
);
});
-QUnit.test('converted select2-tags to data/tags automatically', function (assert) {
- var $test = $(' ');
- var options = new Options({}, $test);
+QUnit.test(
+ 'converted select2-tags to data/tags automatically',
+ function (assert) {
+ var $test = $(' ');
+ var options = new Options({}, $test);
- assert.ok(
- options.get('tags'),
- 'The `tags` key is automatically set to true'
- );
- assert.equal(
- options.get('data'),
- 'original data',
- 'The `data` key is created with the original data'
- );
-});
+ assert.ok(
+ options.get('tags'),
+ 'The `tags` key is automatically set to true'
+ );
+ assert.equal(
+ options.get('data'),
+ 'original data',
+ 'The `data` key is created with the original data'
+ );
+ }
+);
diff --git a/tests/options/translation-tests.js b/tests/options/translation-tests.js
index 00479ec8..ee9bc300 100644
--- a/tests/options/translation-tests.js
+++ b/tests/options/translation-tests.js
@@ -4,7 +4,7 @@ var $ = require('jquery');
var Options = require('select2/options');
var Defaults = require('select2/defaults');
-module('Options - Translations', {
+QUnit.module('Options - Translations', {
beforeEach: function () {
Defaults.reset();
},
@@ -13,20 +13,23 @@ module('Options - Translations', {
}
});
-test('partial dictonaries are reset when default reset', function (assert) {
- Defaults.set('language', {
- test: 'testing'
- });
+QUnit.test(
+ 'partial dictonaries are reset when default reset',
+ function (assert) {
+ Defaults.set('language', {
+ test: 'testing'
+ });
- Defaults.reset();
+ Defaults.reset();
- assert.ok(
- !Defaults.defaults.language.test,
- 'The partial dictionary should have been reset'
- );
-});
+ assert.ok(
+ !Defaults.defaults.language.test,
+ 'The partial dictionary should have been reset'
+ );
+ }
+);
-test('default language chain is English', function (assert) {
+QUnit.test('default language chain is English', function (assert) {
var $element = $(' ');
var options = new Options({}, $element);
@@ -37,7 +40,7 @@ test('default language chain is English', function (assert) {
);
});
-test(
+QUnit.test(
'default translation includes all of the required messages',
function (assert) {
var $element = $(' ');
@@ -86,84 +89,90 @@ QUnit.test('partial dictionaries can be passed', function (assert) {
);
});
-test('partial dictionaries can be combined with defaults', function (assert) {
- var $element = $(' ');
+QUnit.test(
+ 'partial dictionaries can be combined with defaults',
+ function (assert) {
+ var $element = $(' ');
- Defaults.set('language', {
- test: function () {
- return 'Testing';
- }
- });
-
- var options = new Options({
- language: {
- searching: function () {
- return 'Something';
+ Defaults.set('language', {
+ test: function () {
+ return 'Testing';
}
- }
- }, $element);
+ });
- var translations = options.get('translations');
-
- assert.equal(
- translations.get('searching')(),
- 'Something',
- 'The partial dictionary still overrides translations'
- );
-
- assert.equal(
- translations.get('test')(),
- 'Testing',
- 'The defaults were included in the fallback chain'
- );
-
- assert.equal(
- translations.get('noResults')(),
- 'No results found',
- 'You can still get English translations for keys not passed in'
- );
-});
-
-test('partial dictionaries can used in fallback chains', function (assert) {
- var $element = $(' ');
-
- var options = new Options({
- language: [
- {
+ var options = new Options({
+ language: {
searching: function () {
return 'Something';
}
- },
- {
- test: function () {
- return 'Testing';
- }
}
- ]
- }, $element);
+ }, $element);
- var translations = options.get('translations');
+ var translations = options.get('translations');
- assert.equal(
- translations.get('searching')(),
- 'Something',
- 'The partial dictionary still overrides translations'
- );
+ assert.equal(
+ translations.get('searching')(),
+ 'Something',
+ 'The partial dictionary still overrides translations'
+ );
- assert.equal(
- translations.get('test')(),
- 'Testing',
- 'The defaults were included in the fallback chain'
- );
+ assert.equal(
+ translations.get('test')(),
+ 'Testing',
+ 'The defaults were included in the fallback chain'
+ );
- assert.equal(
- translations.get('noResults')(),
- 'No results found',
- 'You can still get English translations for keys not passed in'
- );
-});
+ assert.equal(
+ translations.get('noResults')(),
+ 'No results found',
+ 'You can still get English translations for keys not passed in'
+ );
+ }
+);
-test('language can be set via the options', function (assert) {
+QUnit.test(
+ 'partial dictionaries can used in fallback chains',
+ function (assert) {
+ var $element = $(' ');
+
+ var options = new Options({
+ language: [
+ {
+ searching: function () {
+ return 'Something';
+ }
+ },
+ {
+ test: function () {
+ return 'Testing';
+ }
+ }
+ ]
+ }, $element);
+
+ var translations = options.get('translations');
+
+ assert.equal(
+ translations.get('searching')(),
+ 'Something',
+ 'The partial dictionary still overrides translations'
+ );
+
+ assert.equal(
+ translations.get('test')(),
+ 'Testing',
+ 'The defaults were included in the fallback chain'
+ );
+
+ assert.equal(
+ translations.get('noResults')(),
+ 'No results found',
+ 'You can still get English translations for keys not passed in'
+ );
+ }
+);
+
+QUnit.test('language can be set via the options', function (assert) {
var $element = $(' ');
var options = new Options({
@@ -176,7 +185,7 @@ test('language can be set via the options', function (assert) {
);
});
-test('multi-part language is broken out', function (assert) {
+QUnit.test('multi-part language is broken out', function (assert) {
var $element = $(' ');
var options = new Options({
@@ -189,7 +198,7 @@ test('multi-part language is broken out', function (assert) {
);
});
-test('default language can be set', function (assert) {
+QUnit.test('default language can be set', function (assert) {
var $element = $(' ');
Defaults.set('language', 'es');
@@ -202,7 +211,7 @@ test('default language can be set', function (assert) {
);
});
-test('lanugage set via options adds to default chain', function (assert) {
+QUnit.test('lanugage set via options adds to default chain', function (assert) {
var $element = $(' ');
Defaults.set('language', 'es');
@@ -217,7 +226,7 @@ test('lanugage set via options adds to default chain', function (assert) {
);
});
-test('default language chain can be set', function (assert) {
+QUnit.test('default language chain can be set', function (assert) {
var $element = $(' ');
Defaults.set('language', ['es', 'it', 'en']);
@@ -230,7 +239,7 @@ test('default language chain can be set', function (assert) {
);
});
-test('language can be set by lang attr', function (assert) {
+QUnit.test('language can be set by lang attr', function (assert) {
var $element = $(' ');
var options = new Options({}, $element);
@@ -241,7 +250,7 @@ test('language can be set by lang attr', function (assert) {
);
});
-test('language can be inherited by lang attr', function (assert) {
+QUnit.test('language can be inherited by lang attr', function (assert) {
var $element = $('
').find('select');
var options = new Options({}, $element);
@@ -252,18 +261,23 @@ test('language can be inherited by lang attr', function (assert) {
);
});
-test('multi-part language can be inherited by lang attr', function (assert) {
- var $element = $('
').find('select');
+QUnit.test(
+ 'multi-part language can be inherited by lang attr',
+ function (assert) {
+ var $element = $(
+ '
'
+ ).find('select');
- var options = new Options({}, $element);
+ var options = new Options({}, $element);
- assert.deepEqual(
- options.get('language'),
- ['pt-BR', 'pt', 'en']
- );
-});
+ assert.deepEqual(
+ options.get('language'),
+ ['pt-BR', 'pt', 'en']
+ );
+ }
+);
-test('lang attr overrides default language', function (assert) {
+QUnit.test('lang attr overrides default language', function (assert) {
var $element = $(' ');
Defaults.set('language', 'es');
@@ -276,7 +290,7 @@ test('lang attr overrides default language', function (assert) {
);
});
-test('default language overrides inherited lang attr', function (assert) {
+QUnit.test('default language overrides inherited lang attr', function (assert) {
var $element = $('
').find('select');
Defaults.set('language', 'es');
diff --git a/tests/options/width-tests.js b/tests/options/width-tests.js
index 21e00fe3..c90228a1 100644
--- a/tests/options/width-tests.js
+++ b/tests/options/width-tests.js
@@ -21,13 +21,16 @@ QUnit.test('width from style attribute', function (assert) {
assert.equal(width, '50%');
});
-QUnit.test('width from style returns null if nothing is found', function (assert) {
- var $test = $('');
+QUnit.test(
+ 'width from style returns null if nothing is found',
+ function (assert) {
+ var $test = $('');
- var width = select._resolveWidth($test, 'style');
+ var width = select._resolveWidth($test, 'style');
- assert.equal(width, null);
-});
+ assert.equal(width, null);
+ }
+);
QUnit.test('width from computed element width', function (assert) {
var $style = $(
@@ -51,34 +54,40 @@ QUnit.test('resolve gets the style if it is there', function (assert) {
assert.equal(width, '20%');
});
-QUnit.test('resolve falls back to element if there is no style', function (assert) {
- var $style = $(
- ''
- );
- var $test = $(' ');
+QUnit.test(
+ 'resolve falls back to element if there is no style',
+ function (assert) {
+ var $style = $(
+ ''
+ );
+ var $test = $(' ');
- $('#qunit-fixture').append($style);
- $('#qunit-fixture').append($test);
+ $('#qunit-fixture').append($style);
+ $('#qunit-fixture').append($test);
- var width = select._resolveWidth($test, 'resolve');
+ var width = select._resolveWidth($test, 'resolve');
- assert.equal(width, '500px');
-});
+ assert.equal(width, '500px');
+ }
+);
-QUnit.test('computedstyle gets the style if parent is invisible', function (assert) {
- var $style = $(
- ''
- );
- var $test = $(
- '' +
- ' ' +
- '
'
- );
+QUnit.test(
+ 'computedstyle gets the style if parent is invisible',
+ function (assert) {
+ var $style = $(
+ ''
+ );
+ var $test = $(
+ '' +
+ ' ' +
+ '
'
+ );
- $('#qunit-fixture').append($style);
- $('#qunit-fixture').append($test);
+ $('#qunit-fixture').append($style);
+ $('#qunit-fixture').append($test);
- var width = select._resolveWidth($test.find('select'), 'computedstyle');
+ var width = select._resolveWidth($test.find('select'), 'computedstyle');
- assert.equal(width, '500px');
-});
+ assert.equal(width, '500px');
+ }
+);
diff --git a/tests/results/a11y-tests.js b/tests/results/a11y-tests.js
index 853aba53..3fb568c1 100644
--- a/tests/results/a11y-tests.js
+++ b/tests/results/a11y-tests.js
@@ -14,12 +14,15 @@ QUnit.test('role of results should be a listbox', function (assert) {
assert.equal($results.attr('role'), 'listbox');
});
-QUnit.test('multiple select should have aria-multiselectable', function (assert) {
- var results = new Results($(' '), new Options({
- multiple: true
- }));
+QUnit.test(
+ 'multiple select should have aria-multiselectable',
+ function (assert) {
+ var results = new Results($(' '), new Options({
+ multiple: true
+ }));
- var $results = results.render();
+ var $results = results.render();
- assert.equal($results.attr('aria-multiselectable'), 'true');
-});
+ assert.equal($results.attr('aria-multiselectable'), 'true');
+ }
+);
diff --git a/tests/results/focusing-tests.js b/tests/results/focusing-tests.js
index 41f21480..f1dd0066 100644
--- a/tests/results/focusing-tests.js
+++ b/tests/results/focusing-tests.js
@@ -42,53 +42,56 @@ QUnit.test('results:all with no data skips results:focus', function (assert) {
});
});
-QUnit.test('results:all triggers results:focus on the first item', function (assert) {
- assert.expect(2);
+QUnit.test(
+ 'results:all triggers results:focus on the first item',
+ function (assert) {
+ assert.expect(2);
- var $ = require('jquery');
+ var $ = require('jquery');
- var $select = $(' ');
- var $parent = $('
');
+ var $select = $(' ');
+ var $parent = $('
');
- var $container = $(' ');
- var container = new MockContainer();
+ var $container = $(' ');
+ var container = new MockContainer();
- $parent.appendTo($('#qunit-fixture'));
- $select.appendTo($parent);
+ $parent.appendTo($('#qunit-fixture'));
+ $select.appendTo($parent);
- var Utils = require('select2/utils');
- var Options = require('select2/options');
+ var Utils = require('select2/utils');
+ var Options = require('select2/options');
- var Results = require('select2/results');
+ var Results = require('select2/results');
- var results = new Results($select, new Options({}));
+ var results = new Results($select, new Options({}));
- // Fake the data adapter for the `setClasses` method
- results.data = {};
- results.data.current = function (callback) {
- callback([{ id: 'test' }]);
- };
+ // Fake the data adapter for the `setClasses` method
+ results.data = {};
+ results.data.current = function (callback) {
+ callback([{ id: 'test' }]);
+ };
- results.render();
+ results.render();
- results.bind(container, $container);
+ results.bind(container, $container);
- results.on('results:focus', function (params) {
- assert.equal(params.data.id, 'test');
- assert.equal(params.data.text, 'Test');
- });
+ results.on('results:focus', function (params) {
+ assert.equal(params.data.id, 'test');
+ assert.equal(params.data.text, 'Test');
+ });
- container.trigger('results:all', {
- data: {
- results: [
- {
- id: 'test',
- text: 'Test'
- }
- ]
- }
- });
-});
+ container.trigger('results:all', {
+ data: {
+ results: [
+ {
+ id: 'test',
+ text: 'Test'
+ }
+ ]
+ }
+ });
+ }
+);
QUnit.test('results:append does not trigger results:focus', function (assert) {
assert.expect(0);
@@ -189,53 +192,56 @@ QUnit.test('scrollAfterSelect triggers results:focus', function (assert) {
container.trigger('select', {});
});
-QUnit.test('!scrollAfterSelect does not trigger results:focus', function (assert) {
- assert.expect(1);
+QUnit.test(
+ '!scrollAfterSelect does not trigger results:focus',
+ function (assert) {
+ assert.expect(1);
- var $ = require('jquery');
+ var $ = require('jquery');
- var $select = $(' ');
- var $parent = $('
');
+ var $select = $(' ');
+ var $parent = $('
');
- var $container = $(' ');
- var container = new MockContainer();
+ var $container = $(' ');
+ var container = new MockContainer();
- $parent.appendTo($('#qunit-fixture'));
- $select.appendTo($parent);
+ $parent.appendTo($('#qunit-fixture'));
+ $select.appendTo($parent);
- var Utils = require('select2/utils');
- var Options = require('select2/options');
+ var Utils = require('select2/utils');
+ var Options = require('select2/options');
- var Results = require('select2/results');
+ var Results = require('select2/results');
- var options = new Options({ scrollAfterSelect: false });
- var results = new Results($select, options);
+ var options = new Options({ scrollAfterSelect: false });
+ var results = new Results($select, options);
- // Fake the data adapter for the `setClasses` method
- results.data = {};
- results.data.current = function (callback) {
- callback([{ id: 'test' }]);
- };
+ // Fake the data adapter for the `setClasses` method
+ results.data = {};
+ results.data.current = function (callback) {
+ callback([{ id: 'test' }]);
+ };
- results.render();
+ results.render();
- results.bind(container, $container);
+ results.bind(container, $container);
- // check that default for scrollAfterSelect is false
- assert.equal(options.get('scrollAfterSelect'), false);
+ // check that default for scrollAfterSelect is false
+ assert.equal(options.get('scrollAfterSelect'), false);
- results.append({
- results: [
- {
- id: 'test',
- text: 'Test'
- }
- ]
- });
+ results.append({
+ results: [
+ {
+ id: 'test',
+ text: 'Test'
+ }
+ ]
+ });
- results.on('results:focus', function () {
- assert.ok(false, 'The results:focus event was triggered');
- });
+ results.on('results:focus', function () {
+ assert.ok(false, 'The results:focus event was triggered');
+ });
- container.trigger('select', {});
-});
+ container.trigger('select', {});
+ }
+);
diff --git a/tests/results/infiniteScroll-tests.js b/tests/results/infiniteScroll-tests.js
index 33c721be..76fa8dc1 100644
--- a/tests/results/infiniteScroll-tests.js
+++ b/tests/results/infiniteScroll-tests.js
@@ -1,53 +1,56 @@
QUnit.module('Results - Infinite scrolling');
-QUnit.test('loadingMore is triggered even without a scrollbar', function (assert) {
- assert.expect(1);
+QUnit.test(
+ 'loadingMore is triggered even without a scrollbar',
+ function (assert) {
+ assert.expect(1);
- var $ = require('jquery');
+ var $ = require('jquery');
- var $select = $(' ');
+ var $select = $(' ');
- var $container = $(' ');
- var container = new MockContainer();
+ var $container = $(' ');
+ var container = new MockContainer();
- var Utils = require('select2/utils');
- var Options = require('select2/options');
+ var Utils = require('select2/utils');
+ var Options = require('select2/options');
- var Results = require('select2/results');
- var InfiniteScroll = require('select2/dropdown/infiniteScroll');
+ var Results = require('select2/results');
+ var InfiniteScroll = require('select2/dropdown/infiniteScroll');
- var InfiniteScrollResults = Utils.Decorate(Results, InfiniteScroll);
+ var InfiniteScrollResults = Utils.Decorate(Results, InfiniteScroll);
- var results = new InfiniteScrollResults($select, new Options({}));
+ var results = new InfiniteScrollResults($select, new Options({}));
- // Fake the data adapter for the `setClasses` method
- results.data = {};
- results.data.current = function (callback) {
- callback([{ id: 'test' }]);
- };
+ // Fake the data adapter for the `setClasses` method
+ results.data = {};
+ results.data.current = function (callback) {
+ callback([{ id: 'test' }]);
+ };
- $('#qunit-fixture').append(results.render());
+ $('#qunit-fixture').append(results.render());
- results.bind(container, $container);
+ results.bind(container, $container);
- results.on('query:append', function () {
- assert.ok(true, 'It tried to load more immediately');
- });
+ results.on('query:append', function () {
+ assert.ok(true, 'It tried to load more immediately');
+ });
- container.trigger('results:all', {
- data: {
- results: [
- {
- id: 'test',
- text: 'Test'
+ container.trigger('results:all', {
+ data: {
+ results: [
+ {
+ id: 'test',
+ text: 'Test'
+ }
+ ],
+ pagination: {
+ more: true
}
- ],
- pagination: {
- more: true
}
- }
- });
-});
+ });
+ }
+);
QUnit.test('loadingMore is not triggered without scrolling', function (assert) {
assert.expect(0);
diff --git a/tests/results/option-tests.js b/tests/results/option-tests.js
index c13c24e4..ad2278e7 100644
--- a/tests/results/option-tests.js
+++ b/tests/results/option-tests.js
@@ -6,49 +6,61 @@ var Options = require('select2/options');
var Results = require('select2/results');
-QUnit.test('disabled property on option is respected - enabled', function (assert) {
- var results = new Results($(' '), new Options({}));
+QUnit.test(
+ 'disabled property on option is respected - enabled',
+ function (assert) {
+ var results = new Results($(' '), new Options({}));
- var $option = $(' ');
- var option = results.option({
- element: $option[0]
- });
+ var $option = $(' ');
+ var option = results.option({
+ element: $option[0]
+ });
- assert.notEqual(option.getAttribute('aria-disabled'), 'true');
-});
+ assert.notEqual(option.getAttribute('aria-disabled'), 'true');
+ }
+);
-QUnit.test('disabled property on option is respected - disabled', function (assert) {
- var results = new Results($(' '), new Options({}));
+QUnit.test(
+ 'disabled property on option is respected - disabled',
+ function (assert) {
+ var results = new Results($(' '), new Options({}));
- var $option = $(' ');
- var option = results.option({
- element: $option[0]
- });
+ var $option = $(' ');
+ var option = results.option({
+ element: $option[0]
+ });
- assert.equal(option.getAttribute('aria-disabled'), 'true');
-});
+ assert.equal(option.getAttribute('aria-disabled'), 'true');
+ }
+);
-QUnit.test('disabled property on enabled optgroup is respected', function (assert) {
- var results = new Results($(' '), new Options({}));
+QUnit.test(
+ 'disabled property on enabled optgroup is respected',
+ function (assert) {
+ var results = new Results($(' '), new Options({}));
- var $option = $(' ');
- var option = results.option({
- element: $option[0]
- });
+ var $option = $(' ');
+ var option = results.option({
+ element: $option[0]
+ });
- assert.notEqual(option.getAttribute('aria-disabled'), 'true');
-});
+ assert.notEqual(option.getAttribute('aria-disabled'), 'true');
+ }
+);
-QUnit.test('disabled property on disabled optgroup is respected', function (assert) {
- var results = new Results($(' '), new Options({}));
+QUnit.test(
+ 'disabled property on disabled optgroup is respected',
+ function (assert) {
+ var results = new Results($(' '), new Options({}));
- var $option = $(' ');
- var option = results.option({
- element: $option[0]
- });
+ var $option = $(' ');
+ var option = results.option({
+ element: $option[0]
+ });
- assert.equal(option.getAttribute('aria-disabled'), 'true');
-});
+ assert.equal(option.getAttribute('aria-disabled'), 'true');
+ }
+);
QUnit.test('option in disabled optgroup is disabled', function (assert) {
var results = new Results($(' '), new Options({}));
diff --git a/tests/selection/allowClear-tests.js b/tests/selection/allowClear-tests.js
index c3aa6b4f..baa540ab 100644
--- a/tests/selection/allowClear-tests.js
+++ b/tests/selection/allowClear-tests.js
@@ -42,23 +42,25 @@ QUnit.test('clear is not displayed for single placeholder', function (assert) {
);
});
-QUnit.test('clear is not displayed for multiple placeholder', function (assert) {
- var selection = new AllowClearPlaceholder(
- $('#qunit-fixture .multiple'),
- allowClearOptions
- );
+QUnit.test(
+ 'clear is not displayed for multiple placeholder',
+ function (assert) {
+ var selection = new AllowClearPlaceholder(
+ $('#qunit-fixture .multiple'),
+ allowClearOptions
+ );
- var $selection = selection.render();
+ var $selection = selection.render();
- selection.update([]);
-
- assert.equal(
- $selection.find('.select2-selection__clear').length,
- 0,
- 'The clear icon should not be displayed'
- );
-});
+ selection.update([]);
+ assert.equal(
+ $selection.find('.select2-selection__clear').length,
+ 0,
+ 'The clear icon should not be displayed'
+ );
+ }
+);
QUnit.test('clear is displayed for placeholder', function (assert) {
var selection = new AllowClearPlaceholder(
@@ -178,38 +180,41 @@ QUnit.test('clicking clear will trigger the unselect event', function (assert) {
$remove.trigger('mousedown');
});
-QUnit.test('preventing the unselect event cancels the clearing', function (assert) {
- var $element = $('#qunit-fixture .single-with-placeholder');
+QUnit.test(
+ 'preventing the unselect event cancels the clearing',
+ function (assert) {
+ var $element = $('#qunit-fixture .single-with-placeholder');
- var selection = new AllowClearPlaceholder(
- $element,
- allowClearOptions
- );
- var container = new MockContainer();
+ var selection = new AllowClearPlaceholder(
+ $element,
+ allowClearOptions
+ );
+ var container = new MockContainer();
- var $selection = selection.render();
+ var $selection = selection.render();
- selection.bind(container, $('
'));
+ selection.bind(container, $('
'));
- $element.val('One');
- selection.update([{
- id: 'One',
- text: 'One'
- }]);
+ $element.val('One');
+ selection.update([{
+ id: 'One',
+ text: 'One'
+ }]);
- selection.on('unselect', function (ev) {
- ev.prevented = true;
- });
+ selection.on('unselect', function (ev) {
+ ev.prevented = true;
+ });
- var $remove = $selection.find('.select2-selection__clear');
- $remove.trigger('mousedown');
+ var $remove = $selection.find('.select2-selection__clear');
+ $remove.trigger('mousedown');
- assert.equal(
- $element.val(),
- 'One',
- 'The placeholder should not have been set'
- );
-});
+ assert.equal(
+ $element.val(),
+ 'One',
+ 'The placeholder should not have been set'
+ );
+ }
+);
QUnit.test('clicking clear will trigger the clear event', function (assert) {
assert.expect(5);
@@ -266,38 +271,41 @@ QUnit.test('clicking clear will trigger the clear event', function (assert) {
$remove.trigger('mousedown');
});
-QUnit.test('preventing the clear event cancels the clearing', function (assert) {
- var $element = $('#qunit-fixture .single-with-placeholder');
+QUnit.test(
+ 'preventing the clear event cancels the clearing',
+ function (assert) {
+ var $element = $('#qunit-fixture .single-with-placeholder');
- var selection = new AllowClearPlaceholder(
- $element,
- allowClearOptions
- );
- var container = new MockContainer();
+ var selection = new AllowClearPlaceholder(
+ $element,
+ allowClearOptions
+ );
+ var container = new MockContainer();
- var $selection = selection.render();
+ var $selection = selection.render();
- selection.bind(container, $('
'));
+ selection.bind(container, $('
'));
- $element.val('One');
- selection.update([{
- id: 'One',
- text: 'One'
- }]);
+ $element.val('One');
+ selection.update([{
+ id: 'One',
+ text: 'One'
+ }]);
- selection.on('clear', function (ev) {
- ev.prevented = true;
- });
+ selection.on('clear', function (ev) {
+ ev.prevented = true;
+ });
- var $remove = $selection.find('.select2-selection__clear');
- $remove.trigger('mousedown');
+ var $remove = $selection.find('.select2-selection__clear');
+ $remove.trigger('mousedown');
- assert.equal(
- $element.val(),
- 'One',
- 'The placeholder should not have been set'
- );
-});
+ assert.equal(
+ $element.val(),
+ 'One',
+ 'The placeholder should not have been set'
+ );
+ }
+);
QUnit.test('clear does not work when disabled', function (assert) {
var $element = $('#qunit-fixture .single-with-placeholder');
@@ -330,71 +338,74 @@ QUnit.test('clear does not work when disabled', function (assert) {
);
});
-QUnit.test('clear button doesnt visually break selected options', function (assert) {
- var $element = $(' ');
+QUnit.test(
+ 'clear button doesnt visually break selected options',
+ function (assert) {
+ var $element = $(' ');
- var Selection = Utils.Decorate(
- Utils.Decorate(MultipleSelection, Placeholder),
- AllowClear
- );
+ var Selection = Utils.Decorate(
+ Utils.Decorate(MultipleSelection, Placeholder),
+ AllowClear
+ );
- var selection = new Selection(
- $element,
- allowClearOptions
- );
- var container = new MockContainer();
+ var selection = new Selection(
+ $element,
+ allowClearOptions
+ );
+ var container = new MockContainer();
- var $container = $(
- ' '
- );
- $('#qunit-fixture').append($container);
+ var $container = $(
+ ' '
+ );
+ $('#qunit-fixture').append($container);
- var $selection = selection.render();
- $container.append($selection);
- $container.css('width', '100px');
+ var $selection = selection.render();
+ $container.append($selection);
+ $container.css('width', '100px');
- selection.bind(container, $container);
+ selection.bind(container, $container);
- selection.update([{
- id: '1',
- text: '1'
- }]);
-
- var singleHeight = $container.height();
-
- selection.update([
- {
- id: '10',
- text: '10'
- },
- {
- id: '20',
- text: '20'
- }
- ]);
-
- var doubleHeight = $container.height();
-
- selection.update([
- {
+ selection.update([{
id: '1',
text: '1'
- },
- {
- id: '2',
- text: '2'
- }
- ]);
+ }]);
- assert.notEqual(
- singleHeight,
- doubleHeight,
- 'The height of the two different rows should be different'
- );
+ var singleHeight = $container.height();
- assert.equal(
- $container.height(),
- doubleHeight,
- 'There should be two full lines of selections'
- );
-});
+ selection.update([
+ {
+ id: '10',
+ text: '10'
+ },
+ {
+ id: '20',
+ text: '20'
+ }
+ ]);
+
+ var doubleHeight = $container.height();
+
+ selection.update([
+ {
+ id: '1',
+ text: '1'
+ },
+ {
+ id: '2',
+ text: '2'
+ }
+ ]);
+
+ assert.notEqual(
+ singleHeight,
+ doubleHeight,
+ 'The height of the two different rows should be different'
+ );
+
+ assert.equal(
+ $container.height(),
+ doubleHeight,
+ 'There should be two full lines of selections'
+ );
+ }
+);
diff --git a/tests/selection/multiple-tests.js b/tests/selection/multiple-tests.js
index f681e1c5..e435930f 100644
--- a/tests/selection/multiple-tests.js
+++ b/tests/selection/multiple-tests.js
@@ -144,29 +144,32 @@ QUnit.test('update sets the title to the data title', function (assert) {
);
});
-QUnit.test('update should clear title for placeholder options', function (assert) {
- var selection = new MultipleSelection(
- $('#qunit-fixture .multiple'),
- options
- );
+QUnit.test('update should clear title for placeholder options',
+function (assert) {
+ var selection = new MultipleSelection(
+ $('#qunit-fixture .multiple'),
+ options
+ );
- var $selection = selection.render();
+ var $selection = selection.render();
- selection.update([{
- id: '',
- text: ''
- }]);
+ selection.update([{
+ id: '',
+ text: ''
+ }]);
- var $rendered = $selection.find('.select2-selection__rendered li');
+ var $rendered = $selection.find('.select2-selection__rendered li');
- assert.equal(
- $rendered.attr('title'),
- undefined,
- 'The title should be removed if a placeholder is rendered'
- );
-});
+ assert.equal(
+ $rendered.attr('title'),
+ undefined,
+ 'The title should be removed if a placeholder is rendered'
+ );
+ }
+);
-QUnit.test('update should clear title for options without text', function (assert) {
+QUnit.test(
+ 'update should clear title for options without text', function (assert) {
var selection = new MultipleSelection(
$('#qunit-fixture .multiple'),
options
diff --git a/tests/selection/placeholder-tests.js b/tests/selection/placeholder-tests.js
index 82cc2b4a..c016ef7b 100644
--- a/tests/selection/placeholder-tests.js
+++ b/tests/selection/placeholder-tests.js
@@ -32,18 +32,20 @@ QUnit.test('normalizing placeholder ignores objects', function (assert) {
assert.equal(original, normalized);
});
-QUnit.test('normalizing placeholder gives object for string', function (assert) {
- var selection = new SinglePlaceholder(
- $('#qunit-fixture .single'),
- placeholderOptions
- );
+QUnit.test(
+ 'normalizing placeholder gives object for string',
+ function (assert) {
+ var selection = new SinglePlaceholder(
+ $('#qunit-fixture .single'),
+ placeholderOptions
+ );
- var normalized = selection.normalizePlaceholder('placeholder');
-
- assert.equal(normalized.id, '');
- assert.equal(normalized.text, 'placeholder');
-});
+ var normalized = selection.normalizePlaceholder('placeholder');
+ assert.equal(normalized.id, '');
+ assert.equal(normalized.text, 'placeholder');
+ }
+);
QUnit.test('text is shown for placeholder option on single', function (assert) {
var selection = new SinglePlaceholder(
@@ -60,15 +62,18 @@ QUnit.test('text is shown for placeholder option on single', function (assert) {
assert.equal($selection.text(), 'This is the placeholder');
});
-QUnit.test('placeholder is shown when no options are selected', function (assert) {
- var selection = new SinglePlaceholder(
- $('#qunit-fixture .multiple'),
- placeholderOptions
- );
+QUnit.test(
+ 'placeholder is shown when no options are selected',
+ function (assert) {
+ var selection = new SinglePlaceholder(
+ $('#qunit-fixture .multiple'),
+ placeholderOptions
+ );
- var $selection = selection.render();
+ var $selection = selection.render();
- selection.update([]);
+ selection.update([]);
- assert.equal($selection.text(), 'This is the placeholder');
-});
+ assert.equal($selection.text(), 'This is the placeholder');
+ }
+);
diff --git a/tests/selection/search-a11y-tests.js b/tests/selection/search-a11y-tests.js
index c675e374..fa0ff4ea 100644
--- a/tests/selection/search-a11y-tests.js
+++ b/tests/selection/search-a11y-tests.js
@@ -49,104 +49,116 @@ QUnit.test('aria-autocomplete attribute is present', function (assert) {
);
});
-QUnit.test('aria-activedescendant should not be set initiailly', function (assert) {
- var $select = $('#qunit-fixture .multiple');
+QUnit.test(
+ 'aria-activedescendant should not be set initiailly',
+ function (assert) {
+ var $select = $('#qunit-fixture .multiple');
- var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
- var selection = new CustomSelection($select, options);
- var $selection = selection.render();
+ var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
+ var selection = new CustomSelection($select, options);
+ var $selection = selection.render();
- var container = new MockContainer();
- selection.bind(container, $(' '));
+ var container = new MockContainer();
+ selection.bind(container, $(' '));
- // Update the selection so the search is rendered
- selection.update([]);
+ // Update the selection so the search is rendered
+ selection.update([]);
- var $search = $selection.find('input');
+ var $search = $selection.find('input');
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'The search box should not point to anything when it is first rendered'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'The search box should not point to anything when it is first rendered'
+ );
+ }
+);
-QUnit.test('aria-activedescendant should be set after highlight', function (assert) {
- var $select = $('#qunit-fixture .multiple');
+QUnit.test(
+ 'aria-activedescendant should be set after highlight',
+ function (assert) {
+ var $select = $('#qunit-fixture .multiple');
- var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
- var selection = new CustomSelection($select, options);
- var $selection = selection.render();
+ var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
+ var selection = new CustomSelection($select, options);
+ var $selection = selection.render();
- var container = new MockContainer();
- selection.bind(container, $(' '));
+ var container = new MockContainer();
+ selection.bind(container, $(' '));
- // Update the selection so the search is rendered
- selection.update([]);
+ // Update the selection so the search is rendered
+ selection.update([]);
- container.trigger('results:focus', {
- data: {
- _resultId: 'test'
- }
- });
+ container.trigger('results:focus', {
+ data: {
+ _resultId: 'test'
+ }
+ });
- var $search = $selection.find('input');
+ var $search = $selection.find('input');
- assert.equal(
- $search.attr('aria-activedescendant'),
- 'test',
- 'The search is pointing to the focused result'
- );
-});
+ assert.equal(
+ $search.attr('aria-activedescendant'),
+ 'test',
+ 'The search is pointing to the focused result'
+ );
+ }
+);
-QUnit.test('activedescendant should remove if there is no ID', function (assert) {
- var $select = $('#qunit-fixture .multiple');
+QUnit.test(
+ 'activedescendant should remove if there is no ID',
+ function (assert) {
+ var $select = $('#qunit-fixture .multiple');
- var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
- var selection = new CustomSelection($select, options);
- var $selection = selection.render();
+ var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
+ var selection = new CustomSelection($select, options);
+ var $selection = selection.render();
- var container = new MockContainer();
- selection.bind(container, $(' '));
+ var container = new MockContainer();
+ selection.bind(container, $(' '));
- // Update the selection so the search is rendered
- selection.update([]);
+ // Update the selection so the search is rendered
+ selection.update([]);
- var $search = $selection.find('input');
- $search.attr('aria-activedescendant', 'test');
+ var $search = $selection.find('input');
+ $search.attr('aria-activedescendant', 'test');
- container.trigger('results:focus', {
- data: {}
- });
+ container.trigger('results:focus', {
+ data: {}
+ });
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'There is no result for the search to be pointing to'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'There is no result for the search to be pointing to'
+ );
+ }
+);
-QUnit.test('aria-activedescendant should be removed when closed', function (assert) {
- var $select = $('#qunit-fixture .multiple');
+QUnit.test(
+ 'aria-activedescendant should be removed when closed',
+ function (assert) {
+ var $select = $('#qunit-fixture .multiple');
- var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
- var selection = new CustomSelection($select, options);
- var $selection = selection.render();
+ var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
+ var selection = new CustomSelection($select, options);
+ var $selection = selection.render();
- var container = new MockContainer();
- selection.bind(container, $(' '));
+ var container = new MockContainer();
+ selection.bind(container, $(' '));
- // Update the selection so the search is rendered
- selection.update([]);
+ // Update the selection so the search is rendered
+ selection.update([]);
- var $search = $selection.find('input');
- $search.attr('aria-activedescendant', 'something');
+ var $search = $selection.find('input');
+ $search.attr('aria-activedescendant', 'something');
- container.trigger('close');
+ container.trigger('close');
- assert.ok(
- !$search.attr('aria-activedescendant'),
- 'There is no active descendant when the dropdown is closed'
- );
-});
+ assert.ok(
+ !$search.attr('aria-activedescendant'),
+ 'There is no active descendant when the dropdown is closed'
+ );
+ }
+);
QUnit.test('aria-controls should not be set initiailly', function (assert) {
var $select = $('#qunit-fixture .multiple');
diff --git a/tests/selection/search-tests.js b/tests/selection/search-tests.js
index 1be8c6a3..e7f76057 100644
--- a/tests/selection/search-tests.js
+++ b/tests/selection/search-tests.js
@@ -218,34 +218,37 @@ QUnit.test('search box without text should propagate click', function (assert) {
$search.trigger('click');
});
-QUnit.test('search box with text should not propagate click', function (assert) {
- assert.expect(0);
+QUnit.test(
+ 'search box with text should not propagate click',
+ function (assert) {
+ assert.expect(0);
- var $container = $('#qunit-fixture .event-container');
- var container = new MockContainer();
+ var $container = $('#qunit-fixture .event-container');
+ var container = new MockContainer();
- var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
+ var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
- var $element = $('#qunit-fixture .multiple');
- var selection = new CustomSelection($element, options);
+ var $element = $('#qunit-fixture .multiple');
+ var selection = new CustomSelection($element, options);
- var $selection = selection.render();
- selection.bind(container, $container);
+ var $selection = selection.render();
+ selection.bind(container, $container);
- // Update the selection so the search is rendered
- selection.update([]);
+ // Update the selection so the search is rendered
+ selection.update([]);
- // Make it visible so the browser can place focus on the search
- $container.append($selection);
+ // Make it visible so the browser can place focus on the search
+ $container.append($selection);
- $selection.on('click', function () {
- assert.ok(false, 'The click event should have been trapped');
- });
+ $selection.on('click', function () {
+ assert.ok(false, 'The click event should have been trapped');
+ });
- var $search = $selection.find('input');
- $search.val('test');
- $search.trigger('click');
-});
+ var $search = $selection.find('input');
+ $search.val('test');
+ $search.trigger('click');
+ }
+);
QUnit.test('search box with text should not close dropdown', function (assert) {
assert.expect(0);
diff --git a/tests/selection/single-tests.js b/tests/selection/single-tests.js
index 9563afd3..f926e6d0 100644
--- a/tests/selection/single-tests.js
+++ b/tests/selection/single-tests.js
@@ -159,50 +159,56 @@ QUnit.test('update sets the title to the data title', function (assert) {
);
});
-QUnit.test('update should clear title for placeholder options', function (assert) {
- var selection = new SingleSelection(
- $('#qunit-fixture .single'),
- options
- );
+QUnit.test(
+ 'update should clear title for placeholder options',
+ function (assert) {
+ var selection = new SingleSelection(
+ $('#qunit-fixture .single'),
+ options
+ );
- var $selection = selection.render();
- var $rendered = $selection.find('.select2-selection__rendered');
+ var $selection = selection.render();
+ var $rendered = $selection.find('.select2-selection__rendered');
- $rendered.attr('title', 'testing');
+ $rendered.attr('title', 'testing');
- selection.update([{
- id: '',
- text: ''
- }]);
+ selection.update([{
+ id: '',
+ text: ''
+ }]);
- assert.equal(
- $rendered.attr('title'),
- undefined,
- 'The title should be removed if a placeholder is rendered'
- );
-});
+ assert.equal(
+ $rendered.attr('title'),
+ undefined,
+ 'The title should be removed if a placeholder is rendered'
+ );
+ }
+);
-QUnit.test('update should clear title for options without text', function (assert) {
- var selection = new SingleSelection(
- $('#qunit-fixture .single'),
- options
- );
+QUnit.test(
+ 'update should clear title for options without text',
+ function (assert) {
+ var selection = new SingleSelection(
+ $('#qunit-fixture .single'),
+ options
+ );
- var $selection = selection.render();
- var $rendered = $selection.find('.select2-selection__rendered');
+ var $selection = selection.render();
+ var $rendered = $selection.find('.select2-selection__rendered');
- $rendered.attr('title', 'testing');
+ $rendered.attr('title', 'testing');
- selection.update([{
- id: ''
- }]);
+ selection.update([{
+ id: ''
+ }]);
- assert.equal(
- $rendered.attr('title'),
- undefined,
- 'The title should be removed if there is no text or title property'
- );
-});
+ assert.equal(
+ $rendered.attr('title'),
+ undefined,
+ 'The title should be removed if there is no text or title property'
+ );
+ }
+);
QUnit.test('escapeMarkup is being used', function (assert) {
var selection = new SingleSelection(