diff --git a/tests/data.html b/tests/data.html new file mode 100644 index 00000000..48b44960 --- /dev/null +++ b/tests/data.html @@ -0,0 +1,23 @@ + + + + + + + +
+
+ + + + + + + + + + + + + + diff --git a/tests/data/base.html b/tests/data/base.html deleted file mode 100644 index 6dc9620d..00000000 --- a/tests/data/base.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - -
-
- -
- - - - - - - - - - diff --git a/tests/data/maximumInputLength-tests.js b/tests/data/maximumInputLength-tests.js index a3f5a28b..e8557139 100644 --- a/tests/data/maximumInputLength-tests.js +++ b/tests/data/maximumInputLength-tests.js @@ -5,22 +5,22 @@ var $ = require('jquery'); var Options = require('select2/options'); var Utils = require('select2/utils'); -function StubData () { +function MaximumInputStub () { this.called = false; } -StubData.prototype.query = function (params, callback) { +MaximumInputStub.prototype.query = function (params, callback) { this.called = true; }; -var MaximumData = Utils.Decorate(StubData, MaximumInputLength); +var MaximumInputData = Utils.Decorate(MaximumInputStub, MaximumInputLength); test('0 never displays the notice', function (assert) { var zeroOptions = new Options({ maximumInputLength: 0 }); - var data = new MaximumData(null, zeroOptions); + var data = new MaximumInputData(null, zeroOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -32,7 +32,7 @@ test('0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, zeroOptions); + data = new MaximumInputData(null, zeroOptions); data.query({ term: 'test' @@ -46,7 +46,7 @@ test('< 0 never displays the notice', function (assert) { maximumInputLength: -1 }); - var data = new MaximumData(null, negativeOptions); + var data = new MaximumInputData(null, negativeOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -58,7 +58,7 @@ test('< 0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, negativeOptions); + data = new MaximumInputData(null, negativeOptions); data.query({ term: 'test' @@ -72,7 +72,7 @@ test('triggers when input is too long', function (assert) { maximumInputLength: 1 }); - var data = new MaximumData(null, options); + var data = new MaximumInputData(null, options); data.trigger = function () { assert.ok(true, 'The event should be triggered.'); @@ -82,7 +82,7 @@ test('triggers when input is too long', function (assert) { term: 'no' }); - assert.ok(!data.called); + assert.ok(!data.called, 'The adapter should not be called'); }); test('does not trigger when equal', function (assert) { @@ -90,7 +90,7 @@ test('does not trigger when equal', function (assert) { maximumInputLength: 10 }); - var data = new MaximumData(null, options); + var data = new MaximumInputData(null, options); data.trigger = function () { assert.ok(false, 'The event should not be triggered.'); @@ -108,7 +108,7 @@ test('does not trigger when less', function (assert) { maximumInputLength: 10 }); - var data = new MaximumData(null, options); + var data = new MaximumInputData(null, options); data.trigger = function () { assert.ok(false, 'The event should not be triggered.'); @@ -126,7 +126,7 @@ test('works with null term', function (assert) { maximumInputLength: 1 }); - var data = new MaximumData(null, options); + var data = new MaximumInputData(null, options); data.trigger = function () { assert.ok(false, 'The event should not be triggered'); diff --git a/tests/data/maximumInputLength.html b/tests/data/maximumInputLength.html deleted file mode 100644 index 94787088..00000000 --- a/tests/data/maximumInputLength.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/data/maximumSelectionLength-tests.js b/tests/data/maximumSelectionLength-tests.js index dccaf08f..89943b38 100644 --- a/tests/data/maximumSelectionLength-tests.js +++ b/tests/data/maximumSelectionLength-tests.js @@ -6,31 +6,34 @@ var $ = require('jquery'); var Options = require('select2/options'); var Utils = require('select2/utils'); -function StubData () { +function MaximumSelectionStub () { this.called = false; this.currentData = []; } -StubData.prototype.current = function (callback) { +MaximumSelectionStub.prototype.current = function (callback) { callback(this.currentData); }; -StubData.prototype.val = function (val) { +MaximumSelectionStub.prototype.val = function (val) { this.currentData.push(val); }; -StubData.prototype.query = function (params, callback) { +MaximumSelectionStub.prototype.query = function (params, callback) { this.called = true; }; -var MaximumData = Utils.Decorate(StubData, MaximumSelectionLength); +var MaximumSelectionData = Utils.Decorate( + MaximumSelectionStub, + MaximumSelectionLength +); test('0 never displays the notice', function (assert) { var zeroOptions = new Options({ maximumSelectionLength: 0 }); - var data = new MaximumData(null, zeroOptions); + var data = new MaximumSelectionData(null, zeroOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -42,7 +45,7 @@ test('0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, zeroOptions); + data = new MaximumSelectionData(null, zeroOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -56,7 +59,7 @@ test('0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, zeroOptions); + data = new MaximumSelectionData(null, zeroOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -77,7 +80,7 @@ test('< 0 never displays the notice', function (assert) { maximumSelectionLength: -1 }); - var data = new MaximumData(null, negativeOptions); + var data = new MaximumSelectionData(null, negativeOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -89,7 +92,7 @@ test('< 0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, negativeOptions); + data = new MaximumSelectionData(null, negativeOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -103,7 +106,7 @@ test('< 0 never displays the notice', function (assert) { assert.ok(data.called); - data = new MaximumData(null, negativeOptions); + data = new MaximumSelectionData(null, negativeOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -123,7 +126,7 @@ test('triggers when >= 1 selection' , function (assert) { var maxOfOneOptions = new Options({ maximumSelectionLength: 1 }); - var data = new MaximumData(null, maxOfOneOptions); + var data = new MaximumSelectionData(null, maxOfOneOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -135,7 +138,7 @@ test('triggers when >= 1 selection' , function (assert) { assert.ok(data.called); - data = new MaximumData(null, maxOfOneOptions); + data = new MaximumSelectionData(null, maxOfOneOptions); data.trigger = function () { assert.ok(true, 'The event should be triggered.'); @@ -155,7 +158,7 @@ test('triggers when >= 2 selections' , function (assert) { var maxOfTwoOptions = new Options({ maximumSelectionLength: 2 }); - var data = new MaximumData(null, maxOfTwoOptions); + var data = new MaximumSelectionData(null, maxOfTwoOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -167,7 +170,7 @@ test('triggers when >= 2 selections' , function (assert) { assert.ok(data.called); - data = new MaximumData(null, maxOfTwoOptions); + data = new MaximumSelectionData(null, maxOfTwoOptions); data.trigger = function () { assert.ok(false, 'No events should be triggered'); @@ -181,7 +184,7 @@ test('triggers when >= 2 selections' , function (assert) { assert.ok(data.called); - data = new MaximumData(null, maxOfTwoOptions); + data = new MaximumSelectionData(null, maxOfTwoOptions); data.trigger = function () { assert.ok(true, 'The event should be triggered.'); @@ -196,4 +199,4 @@ test('triggers when >= 2 selections' , function (assert) { assert.ok(!data.called); -}); \ No newline at end of file +}); diff --git a/tests/data/maximumSelectionLength.html b/tests/data/maximumSelectionLength.html deleted file mode 100644 index 9501868a..00000000 --- a/tests/data/maximumSelectionLength.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - -
-
-
- - - - - - - - - - diff --git a/tests/data/minimumInputLength.html b/tests/data/minimumInputLength.html deleted file mode 100644 index 6665a245..00000000 --- a/tests/data/minimumInputLength.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/dropdown.html b/tests/dropdown.html new file mode 100644 index 00000000..99943763 --- /dev/null +++ b/tests/dropdown.html @@ -0,0 +1,24 @@ + + + + + + + +
+
+
+ +
+
+ + + + + + + + + + + diff --git a/tests/dropdown/selectOnClose.html b/tests/dropdown/selectOnClose.html deleted file mode 100644 index 8f3ffe26..00000000 --- a/tests/dropdown/selectOnClose.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/dropdown/stopPropagation.html b/tests/dropdown/stopPropagation.html deleted file mode 100644 index 10a24338..00000000 --- a/tests/dropdown/stopPropagation.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - -
-
-
- -
-
- - - - - - - - - - diff --git a/tests/options.html b/tests/options.html new file mode 100644 index 00000000..160f77e2 --- /dev/null +++ b/tests/options.html @@ -0,0 +1,27 @@ + + + + + + + + + +
+
+ + + + + + + + + + + + diff --git a/tests/options/data.html b/tests/options/data.html deleted file mode 100644 index 90bf9a00..00000000 --- a/tests/options/data.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/options/deprecated.html b/tests/options/deprecated.html deleted file mode 100644 index db86173b..00000000 --- a/tests/options/deprecated.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/options/width.html b/tests/options/width.html deleted file mode 100644 index 5dfddb25..00000000 --- a/tests/options/width.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/selection.html b/tests/selection.html new file mode 100644 index 00000000..f5877ae7 --- /dev/null +++ b/tests/selection.html @@ -0,0 +1,37 @@ + + + + + + + +
+
+ + + + + +
+ + + + + + + + + + + + + + diff --git a/tests/selection/allowClear-tests.js b/tests/selection/allowClear-tests.js index c46b0fb2..e7f4fd86 100644 --- a/tests/selection/allowClear-tests.js +++ b/tests/selection/allowClear-tests.js @@ -9,12 +9,12 @@ var $ = require('jquery'); var Options = require('select2/options'); var Utils = require('select2/utils'); -var SinglePlaceholder = Utils.Decorate( +var AllowClearPlaceholder = Utils.Decorate( Utils.Decorate(SingleSelection, Placeholder), AllowClear ); -var options = new Options({ +var allowClearOptions = new Options({ placeholder: { id: 'placeholder', text: 'This is the placeholder' @@ -23,9 +23,9 @@ var options = new Options({ }); test('clear is not displayed for single placeholder', function (assert) { - var selection = new SinglePlaceholder( - $('#qunit-fixture .single'), - options + var selection = new AllowClearPlaceholder( + $('#qunit-fixture .single-with-placeholder'), + allowClearOptions ); var $selection = selection.render(); @@ -42,9 +42,9 @@ test('clear is not displayed for single placeholder', function (assert) { }); test('clear is not displayed for multiple placeholder', function (assert) { - var selection = new SinglePlaceholder( - $('#qunit-fixture .single'), - options + var selection = new AllowClearPlaceholder( + $('#qunit-fixture .single-with-placeholder'), + allowClearOptions ); var $selection = selection.render(); @@ -60,9 +60,9 @@ test('clear is not displayed for multiple placeholder', function (assert) { test('clear is displayed for placeholder', function (assert) { - var selection = new SinglePlaceholder( - $('#qunit-fixture .single'), - options + var selection = new AllowClearPlaceholder( + $('#qunit-fixture .single-with-placeholder'), + allowClearOptions ); var $selection = selection.render(); @@ -80,11 +80,11 @@ test('clear is displayed for placeholder', function (assert) { }); test('clicking clear will set the placeholder value', function (assert) { - var $element = $('#qunit-fixture .single'); + var $element = $('#qunit-fixture .single-with-placeholder'); - var selection = new SinglePlaceholder( + var selection = new AllowClearPlaceholder( $element, - options + allowClearOptions ); var container = new MockContainer(); @@ -111,11 +111,11 @@ test('clicking clear will set the placeholder value', function (assert) { test('clicking clear will trigger the unselect event', function (assert) { expect(3); - var $element = $('#qunit-fixture .single'); + var $element = $('#qunit-fixture .single-with-placeholder'); - var selection = new SinglePlaceholder( + var selection = new AllowClearPlaceholder( $element, - options + allowClearOptions ); var container = new MockContainer(); @@ -154,11 +154,11 @@ test('clicking clear will trigger the unselect event', function (assert) { test('preventing the unselect event cancels the clearing', function (assert) { - var $element = $('#qunit-fixture .single'); + var $element = $('#qunit-fixture .single-with-placeholder'); - var selection = new SinglePlaceholder( + var selection = new AllowClearPlaceholder( $element, - options + allowClearOptions ); var container = new MockContainer(); @@ -187,11 +187,11 @@ test('preventing the unselect event cancels the clearing', function (assert) { }); test('clear does not work when disabled', function (assert) { - var $element = $('#qunit-fixture .single'); + var $element = $('#qunit-fixture .single-with-placeholder'); - var selection = new SinglePlaceholder( + var selection = new AllowClearPlaceholder( $element, - options + allowClearOptions ); var container = new MockContainer(); diff --git a/tests/selection/allowClear.html b/tests/selection/allowClear.html deleted file mode 100644 index 48135d7b..00000000 --- a/tests/selection/allowClear.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - -
-
- - - -
- - - - - - - - - - diff --git a/tests/selection/multiple.html b/tests/selection/multiple.html deleted file mode 100644 index cd201207..00000000 --- a/tests/selection/multiple.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - -
-
- -
- - - - - - - - - - diff --git a/tests/selection/placeholder-tests.js b/tests/selection/placeholder-tests.js index 11092f35..8a436ff3 100644 --- a/tests/selection/placeholder-tests.js +++ b/tests/selection/placeholder-tests.js @@ -9,7 +9,7 @@ var Utils = require('select2/utils'); var SinglePlaceholder = Utils.Decorate(SingleSelection, Placeholder); -var options = new Options({ +var placeholderOptions = new Options({ placeholder: { id: 'placeholder', text: 'This is the placeholder' @@ -19,7 +19,7 @@ var options = new Options({ test('normalizing placeholder ignores objects', function (assert) { var selection = new SinglePlaceholder( $('#qunit-fixture .single'), - options + placeholderOptions ); var original = { @@ -35,7 +35,7 @@ test('normalizing placeholder ignores objects', function (assert) { test('normalizing placeholder gives object for string', function (assert) { var selection = new SinglePlaceholder( $('#qunit-fixture .single'), - options + placeholderOptions ); var normalized = selection.normalizePlaceholder('placeholder'); @@ -48,7 +48,7 @@ test('normalizing placeholder gives object for string', function (assert) { test('text is shown for placeholder option on single', function (assert) { var selection = new SinglePlaceholder( $('#qunit-fixture .single'), - options + placeholderOptions ); var $selection = selection.render(); @@ -63,7 +63,7 @@ test('text is shown for placeholder option on single', function (assert) { test('placeholder is shown when no options are selected', function (assert) { var selection = new SinglePlaceholder( $('#qunit-fixture .multiple'), - options + placeholderOptions ); var $selection = selection.render(); diff --git a/tests/selection/placeholder.html b/tests/selection/placeholder.html deleted file mode 100644 index a618dbc1..00000000 --- a/tests/selection/placeholder.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - -
-
- - - -
- - - - - - - - - - diff --git a/tests/selection/single.html b/tests/selection/single.html deleted file mode 100644 index 51774631..00000000 --- a/tests/selection/single.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - -
-
- -
- - - - - - - - - - diff --git a/tests/utils.html b/tests/utils.html new file mode 100644 index 00000000..2cf4859a --- /dev/null +++ b/tests/utils.html @@ -0,0 +1,20 @@ + + + + + + + +
+
+ + + + + + + + + + + diff --git a/tests/utils/decorator.html b/tests/utils/decorator.html deleted file mode 100644 index 38eb1d6f..00000000 --- a/tests/utils/decorator.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - - diff --git a/tests/utils/escapeMarkup.html b/tests/utils/escapeMarkup.html deleted file mode 100644 index b57c09b5..00000000 --- a/tests/utils/escapeMarkup.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
-
- - - - - - - - - -