1
0
mirror of synced 2024-11-29 16:16:02 +03:00

Added a few more tests

This adds a test that makes sure that the inline data attribute
overrides the options that are passed in during initialization.

This also adds a test for the `createTag` option, which is used
when tagging.
This commit is contained in:
Kevin Brown 2015-01-11 16:28:33 -05:00
parent 6a5127ac0f
commit ff596e692e
2 changed files with 42 additions and 1 deletions

View File

@ -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);
});
});

View File

@ -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 = $('<select data-override="yes" data-data="yes"></select>');
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');
});