Browse Source

Fix failing tests.

test/unit/query/(search, sort).js
	-Fix the tests that started failing as a result of 144b72c.
pull/113/head
Severyn Kozak 10 years ago
parent
commit
d7c4409e20
  1. 12
      test/unit/query/search.js
  2. 25
      test/unit/query/sort.js

12
test/unit/query/search.js

@ -46,6 +46,16 @@ var sort = [
'type': 'number', 'type': 'number',
'order': 'desc' '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 ){ for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common); module.exports.tests[testCase](test, common);
} }
}; };

25
test/unit/query/sort.js

@ -9,7 +9,8 @@ module.exports.tests = {};
module.exports.tests.interface = function(test, common) { module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) { 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(); t.end();
}); });
}; };
@ -50,12 +51,30 @@ var expected = [
module.exports.tests.query = function(test, common) { module.exports.tests.query = function(test, common) {
test('valid part of query', function(t) { test('valid part of query', function(t) {
var sort = generate; var sort = generate();
t.deepEqual(sort, expected, 'valid sort part of the query'); t.deepEqual(sort, expected, 'valid sort part of the query');
t.end(); 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) { module.exports.all = function (tape, common) {
function test(name, testFunction) { function test(name, testFunction) {
@ -65,4 +84,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common); module.exports.tests[testCase](test, common);
} }
}; };

Loading…
Cancel
Save