From d9c1cbc976125bc6fef764cb0f845c653e5dee9d Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Fri, 21 Aug 2015 18:32:10 -0400 Subject: [PATCH] Add tests for d08cb87 --- tests/data/tokenizer-tests.js | 43 +++++++++++++++++++++++++++++++++++ tests/unit.html | 1 + 2 files changed, 44 insertions(+) create mode 100644 tests/data/tokenizer-tests.js diff --git a/tests/data/tokenizer-tests.js b/tests/data/tokenizer-tests.js new file mode 100644 index 00000000..bce06a2f --- /dev/null +++ b/tests/data/tokenizer-tests.js @@ -0,0 +1,43 @@ +module('Data adaptor - Tokenizer'); + +test('triggers the select event', function (assert) { + expect(2); + + 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 .single'); + + var options = new Options({ + tags: true, + tokenSeparators: [','] + }); + + var container = new MockContainer(); + container.dropdown = container.selection = {}; + + var $container = $('
'); + + 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' + }, function () { + assert.ok(true, 'The callback should have succeeded'); + }); +}); \ No newline at end of file diff --git a/tests/unit.html b/tests/unit.html index f130199c..5b34b95c 100644 --- a/tests/unit.html +++ b/tests/unit.html @@ -61,6 +61,7 @@ +