Skip to content

Commit

Permalink
Added test for new insertTag option
Browse files Browse the repository at this point in the history
This adds a basic test that ensures that the `insertTag` option works as
expected.
  • Loading branch information
kevin-brown committed Jan 4, 2016
1 parent e842797 commit db5e947
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/data/tags-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -238,4 +258,4 @@ test('the createTag options customizes the function', function (assert) {
assert.equal(item.text, 'test');
assert.equal(item.tag, true);
});
});
});

0 comments on commit db5e947

Please sign in to comment.