diff --git a/test/unit/query/search.js b/test/unit/query/search.js index 82a23239..49c83207 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -46,6 +46,16 @@ var sort = [ 'type': 'number', 'order': 'desc' } + }, + { + _script: { + params: { + input: 'test' + }, + file: 'exact_match', + type: 'number', + order: 'desc' + } } ]; @@ -227,4 +237,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +}; diff --git a/test/unit/query/sort.js b/test/unit/query/sort.js index 4c3e6249..8ecd580e 100644 --- a/test/unit/query/sort.js +++ b/test/unit/query/sort.js @@ -9,7 +9,8 @@ module.exports.tests = {}; module.exports.tests.interface = function(test, common) { test('valid interface', function(t) { - t.equal(typeof generate, 'object', 'valid object'); + t.equal(typeof generate(), 'object', 'valid object'); + t.equal(typeof generate({input: 'foobar'}), 'object', 'valid object'); t.end(); }); }; @@ -50,12 +51,30 @@ var expected = [ module.exports.tests.query = function(test, common) { test('valid part of query', function(t) { - var sort = generate; + var sort = generate(); t.deepEqual(sort, expected, 'valid sort part of the query'); t.end(); }); }; +module.exports.tests.queryWithInput = function ( test, common ){ + test( 'Valid sort query component when input is present.', function ( t ){ + var expectedWithInput = expected.slice(); + expectedWithInput.push({ + _script: { + params: { + input: 'foobar' + }, + file: 'exact_match', + type: 'number', + order: 'desc' + } + }); + t.deepEqual(generate({ input: 'foobar' }), expectedWithInput, 'valid sort part of the query'); + t.end(); + }); +}; + module.exports.all = function (tape, common) { function test(name, testFunction) { @@ -65,4 +84,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +};