diff --git a/tests/data/tags-tests.js b/tests/data/tags-tests.js index fd74e034..c20e74f5 100644 --- a/tests/data/tags-tests.js +++ b/tests/data/tags-tests.js @@ -12,7 +12,7 @@ var options = new Options({ tags: true }); -test('does not trigger on blank/null terms', function (assert) { +test('does not trigger on blank or null terms', function (assert) { var data = new SelectTags($('#qunit-fixture .single'), options); data.query({ @@ -185,3 +185,31 @@ test('createTag returns null for no tag', function (assert) { assert.equal(data.results.length, 1); }); }); + +test('the createTag options customizes the function', function (assert) { + var data = new SelectTags( + $('#qunit-fixture .single'), + new Options({ + tags: true, + createTag: function (params) { + return { + id: params.term, + text: params.term, + tag: true + }; + } + }) + ); + + data.query({ + term: 'test' + }, function (data) { + assert.equal(data.results.length, 1); + + var item = data.results[0]; + + assert.equal(item.id, 'test'); + assert.equal(item.text, 'test'); + assert.equal(item.tag, true); + }); +}); diff --git a/tests/options/data-tests.js b/tests/options/data-tests.js index 1b94070c..9449d1d7 100644 --- a/tests/options/data-tests.js +++ b/tests/options/data-tests.js @@ -18,3 +18,16 @@ test('with nesting', function (assert) { assert.ok(!(options.get('first-Second'))); assert.equal(options.get('first').second, 'test'); }); + +test('overrides initialized data', function (assert) { + var $test = $(''); + + var options = new Options({ + options: 'yes', + override: 'no' + }, $test); + + assert.equal(options.get('options'), 'yes'); + assert.equal(options.get('override'), 'yes'); + assert.equal(options.get('data'), 'yes'); +});