diff options
author | Marvin Borner | 2018-07-13 19:06:45 +0200 |
---|---|---|
committer | Marvin Borner | 2018-07-13 19:06:45 +0200 |
commit | 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 (patch) | |
tree | dbc87ef16fa01d5d99116de283592b8fe5e02944 /public/bower_components/select2/tests/data/maximumInputLength-tests.js | |
parent | dfd839f27146df0ad0494e11734fc7d310c70ebf (diff) |
Fixed many permissions and began admin interface
Diffstat (limited to 'public/bower_components/select2/tests/data/maximumInputLength-tests.js')
-rw-r--r-- | public/bower_components/select2/tests/data/maximumInputLength-tests.js | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/public/bower_components/select2/tests/data/maximumInputLength-tests.js b/public/bower_components/select2/tests/data/maximumInputLength-tests.js new file mode 100644 index 0000000..e855713 --- /dev/null +++ b/public/bower_components/select2/tests/data/maximumInputLength-tests.js @@ -0,0 +1,138 @@ +module('Data adapters - Maximum input length'); + +var MaximumInputLength = require('select2/data/maximumInputLength'); +var $ = require('jquery'); +var Options = require('select2/options'); +var Utils = require('select2/utils'); + +function MaximumInputStub () { + this.called = false; +} + +MaximumInputStub.prototype.query = function (params, callback) { + this.called = true; +}; + +var MaximumInputData = Utils.Decorate(MaximumInputStub, MaximumInputLength); + +test('0 never displays the notice', function (assert) { + var zeroOptions = new Options({ + maximumInputLength: 0 + }); + + var data = new MaximumInputData(null, zeroOptions); + + data.trigger = function () { + assert.ok(false, 'No events should be triggered'); + }; + + data.query({ + term: '' + }); + + assert.ok(data.called); + + data = new MaximumInputData(null, zeroOptions); + + data.query({ + term: 'test' + }); + + assert.ok(data.called); +}); + +test('< 0 never displays the notice', function (assert) { + var negativeOptions = new Options({ + maximumInputLength: -1 + }); + + var data = new MaximumInputData(null, negativeOptions); + + data.trigger = function () { + assert.ok(false, 'No events should be triggered'); + }; + + data.query({ + term: '' + }); + + assert.ok(data.called); + + data = new MaximumInputData(null, negativeOptions); + + data.query({ + term: 'test' + }); + + assert.ok(data.called); +}); + +test('triggers when input is too long', function (assert) { + var options = new Options({ + maximumInputLength: 1 + }); + + var data = new MaximumInputData(null, options); + + data.trigger = function () { + assert.ok(true, 'The event should be triggered.'); + }; + + data.query({ + term: 'no' + }); + + assert.ok(!data.called, 'The adapter should not be called'); +}); + +test('does not trigger when equal', function (assert) { + var options = new Options({ + maximumInputLength: 10 + }); + + var data = new MaximumInputData(null, options); + + data.trigger = function () { + assert.ok(false, 'The event should not be triggered.'); + }; + + data.query({ + term: '1234567890' + }); + + assert.ok(data.called); +}); + +test('does not trigger when less', function (assert) { + var options = new Options({ + maximumInputLength: 10 + }); + + var data = new MaximumInputData(null, options); + + data.trigger = function () { + assert.ok(false, 'The event should not be triggered.'); + }; + + data.query({ + term: '123' + }); + + assert.ok(data.called); +}); + +test('works with null term', function (assert) { + var options = new Options({ + maximumInputLength: 1 + }); + + var data = new MaximumInputData(null, options); + + data.trigger = function () { + assert.ok(false, 'The event should not be triggered'); + }; + + data.query({}); + + assert.ok(data.called); +}); |