From db5e947664aca0e9b84db437f1009bd28a03b86b Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Sun, 3 Jan 2016 19:09:45 -0500 Subject: [PATCH] Added test for new insertTag option This adds a basic test that ensures that the `insertTag` option works as expected. --- tests/data/tags-tests.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/data/tags-tests.js b/tests/data/tags-tests.js index 60c7232e..95b3fdeb 100644 --- a/tests/data/tags-tests.js +++ b/tests/data/tags-tests.js @@ -176,6 +176,26 @@ test('insertTag controls the tag location', function (assert) { }); }); +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); + + var item = data.results[1]; + + assert.equal(item.id, 'o'); + assert.equal(item.text, 'o'); + }); +}); + test('createTag controls the tag object', function (assert) { var data = new SelectTags($('#qunit-fixture .single'), options); @@ -238,4 +258,4 @@ test('the createTag options customizes the function', function (assert) { assert.equal(item.text, 'test'); assert.equal(item.tag, true); }); -}); +}); \ No newline at end of file