Added tests for multiple tags and tokenizing
This adds tests to ensure that 3b8cd2e369
will continue to work in the future.
This commit is contained in:
parent
3b8cd2e369
commit
120672dce7
@ -25,7 +25,7 @@ test('triggers the select event', function (assert) {
|
||||
|
||||
var container = new MockContainer();
|
||||
container.dropdown = container.selection = {};
|
||||
|
||||
|
||||
var $container = $('<div></div>');
|
||||
|
||||
var data = new TokenizedSelect($select, options);
|
||||
@ -168,4 +168,52 @@ test('createTag returning null does not cut the term', function (assert) {
|
||||
}, function () {
|
||||
assert.ok(true, 'The callback should have succeeded');
|
||||
});
|
||||
});
|
||||
|
||||
test('works with multiple tokens given', function (assert) {
|
||||
expect(4);
|
||||
|
||||
var SelectData = require('select2/data/select');
|
||||
var Tokenizer = require('select2/data/tokenizer');
|
||||
var Tags = require('select2/data/tags');
|
||||
|
||||
var Options = require('select2/options');
|
||||
var Utils = require('select2/utils');
|
||||
|
||||
var $ = require('jquery');
|
||||
|
||||
var TokenizedSelect = Utils.Decorate(
|
||||
Utils.Decorate(SelectData, Tags),
|
||||
Tokenizer
|
||||
);
|
||||
var $select = $('#qunit-fixture .multiple');
|
||||
|
||||
var options = new Options({
|
||||
tags: true,
|
||||
tokenSeparators: [',']
|
||||
});
|
||||
|
||||
var container = new MockContainer();
|
||||
container.dropdown = container.selection = {};
|
||||
|
||||
var $container = $('<div></div>');
|
||||
|
||||
var data = new TokenizedSelect($select, options);
|
||||
data.bind(container, $container);
|
||||
|
||||
data.on('select', function () {
|
||||
assert.ok(true, 'The select event should be triggered');
|
||||
});
|
||||
|
||||
data.query({
|
||||
term: 'first,second,third'
|
||||
}, function () {
|
||||
assert.ok(true, 'The callback should have succeeded');
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
$select.children('option').length,
|
||||
3,
|
||||
'The two new tags should have been created'
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user