Browse Source

adding 'locality', 'local_admin' to the list of layers (part of admin alias) plus tests

pull/98/head
Harish Krishna 10 years ago
parent
commit
5094ecb25e
  1. 2
      helper/layers.js
  2. 2
      query/indeces.js
  3. 2
      test/unit/query/indeces.js
  4. 4
      test/unit/sanitiser/coarse.js
  5. 8
      test/unit/sanitiser/suggest.js

2
helper/layers.js

@ -13,7 +13,7 @@ module.exports = function(alias_layers) {
};
layers = expand_aliases('poi', layers, ['geoname','osmnode','osmway']);
layers = expand_aliases('admin', layers, ['admin0','admin1','admin2','neighborhood']);
layers = expand_aliases('admin', layers, ['admin0','admin1','admin2','neighborhood','locality','local_admin']);
layers = expand_aliases('address', layers, ['osmaddress','openaddresses']);
// de-dupe

2
query/indeces.js

@ -9,6 +9,8 @@ module.exports = [
'admin1',
'admin2',
'neighborhood',
'locality',
'local_admin',
'osmaddress',
'openaddresses'
];

2
test/unit/query/indeces.js

@ -6,7 +6,7 @@ module.exports.tests = {};
module.exports.tests.interface = function(test, common) {
test('valid interface', function(t) {
t.true(Array.isArray(indeces), 'valid array');
t.equal(indeces.length, 9, 'valid array');
t.equal(indeces.length, 11, 'valid array');
t.end();
});
};

4
test/unit/sanitiser/coarse.js

@ -2,7 +2,7 @@
var coarse = require('../../../sanitiser/coarse'),
_sanitize = coarse.sanitize,
middleware = coarse.middleware,
valid_layers = [ 'admin0', 'admin1', 'admin2', 'neighborhood' ],
valid_layers = [ 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin' ],
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };
module.exports.tests = {};
@ -51,7 +51,7 @@ module.exports.tests.middleware_success = function(test, common) {
var defaultClean = {
input: 'test',
size: 10,
layers: [ 'admin0', 'admin1', 'admin2', 'neighborhood' ],
layers: [ 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin' ],
lat: 0,
lon: 0
};

8
test/unit/sanitiser/suggest.js

@ -7,7 +7,7 @@ var suggest = require('../../../sanitiser/suggest'),
defaultClean = { input: 'test',
lat:0,
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'osmaddress', 'openaddresses' ],
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
lon: 0,
size: 10
},
@ -258,7 +258,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
});
});
test('admin (alias) layer', function(t) {
var admin_layers = ['admin0','admin1','admin2','neighborhood'];
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin'];
sanitize({ layers: 'admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, admin_layers, 'admin layers set');
t.end();
@ -280,7 +280,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
});
});
test('admin alias layer plus regular layers', function(t) {
var admin_layers = ['admin0','admin1','admin2','neighborhood'];
var admin_layers = ['admin0','admin1','admin2','neighborhood','locality','local_admin'];
var reg_layers = ['geoname', 'osmway'];
sanitize({ layers: 'admin,geoname,osmway', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, reg_layers.concat(admin_layers), 'admin + regular layers set');
@ -303,7 +303,7 @@ module.exports.tests.sanitize_layers = function(test, common) {
});
});
test('multiple alias layers (no duplicates)', function(t) {
var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood'];
var alias_layers = ['geoname','osmnode','osmway','admin0','admin1','admin2','neighborhood','locality','local_admin'];
sanitize({ layers: 'poi,admin', input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.deepEqual(clean.layers, alias_layers, 'all layers found (no duplicates)');
t.end();

Loading…
Cancel
Save