Browse Source

testing sort part of the query

pull/67/head
Harish Krishna 10 years ago
parent
commit
6c802dfa1d
  1. 52
      test/unit/query/sort.js
  2. 1
      test/unit/run.js

52
test/unit/query/sort.js

@ -0,0 +1,52 @@
var generate = require('../../../query/sort');
var population = 'population';
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) {
t.equal(typeof generate, 'object', 'valid object');
t.end();
});
};
var expected = [
{
'_script': {
'file': population,
'type': 'number',
'order': 'desc'
}
},
{
'_script': {
'params': {
'weights': weights
},
'file': 'weights',
'type': 'number',
'order': 'desc'
}
}
];
module.exports.tests.query = function(test, common) {
test('valid part of query', function(t) {
var sort = generate;
t.deepEqual(sort, expected, 'valid sort part of the query');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('sort query ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

1
test/unit/run.js

@ -15,6 +15,7 @@ var tests = [
require('./sanitiser/coarse'),
require('./query/indeces'),
require('./query/suggest'),
require('./query/sort'),
require('./query/search'),
require('./query/reverse'),
require('./helper/geojsonify'),

Loading…
Cancel
Save