Browse Source

Merge branch 'master' into split-comma-admin

pull/68/head
Harish Krishna 10 years ago
parent
commit
40b638d85c
  1. 2
      query/sort.js
  2. 15
      test/unit/query/reverse.js
  3. 15
      test/unit/query/search.js
  4. 52
      test/unit/query/sort.js
  5. 1
      test/unit/run.js

2
query/sort.js

@ -4,7 +4,7 @@ var weights = require('pelias-suggester-pipeline').weights;
module.exports = [
{
'_script': {
'file': 'population',
'file': population,
'type': 'number',
'order': 'desc'
}

15
test/unit/query/reverse.js

@ -1,5 +1,6 @@
var generate = require('../../../query/reverse');
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
@ -22,19 +23,7 @@ var sort = [
{
'_script': {
'params': {
'weights': {
'geoname': 0,
'address': 4,
'osmnode': 6,
'osmway': 6,
'poi-address': 8,
'neighborhood': 10,
'local_admin': 12,
'locality': 12,
'admin2': 12,
'admin1': 14,
'admin0': 2
}
'weights': weights
},
'file': 'weights',
'type': 'number',

15
test/unit/query/search.js

@ -1,5 +1,6 @@
var generate = require('../../../query/search');
var weights = require('pelias-suggester-pipeline').weights;
module.exports.tests = {};
@ -22,19 +23,7 @@ var sort = [
{
'_script': {
'params': {
'weights': {
'geoname': 0,
'address': 4,
'osmnode': 6,
'osmway': 6,
'poi-address': 8,
'neighborhood': 10,
'local_admin': 12,
'locality': 12,
'admin2': 12,
'admin1': 14,
'admin0': 2
}
'weights': weights
},
'file': 'weights',
'type': 'number',

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