|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
|
|
|
|
|
var search = require('../../../sanitiser/search'), |
|
|
|
|
defaultParsed = require('../sanitiser/_input').defaultParsed, |
|
|
|
|
_sanitize = search.sanitize, |
|
|
|
|
middleware = search.middleware, |
|
|
|
|
delim = ',', |
|
|
|
@ -8,7 +9,8 @@ var search = require('../../../sanitiser/search'),
|
|
|
|
|
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
|
|
|
|
|
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
|
|
|
|
|
size: 10, |
|
|
|
|
details: true |
|
|
|
|
details: true, |
|
|
|
|
parsed_input: defaultParsed |
|
|
|
|
}, |
|
|
|
|
sanitize = function(query, cb) { _sanitize({'query':query}, cb); }; |
|
|
|
|
|
|
|
|
@ -47,7 +49,7 @@ module.exports.tests.sanitize_input = function(test, common) {
|
|
|
|
|
var expected = JSON.parse(JSON.stringify( defaultClean )); |
|
|
|
|
expected.input = input; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (' + input + ')'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (' + input + ')');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -70,7 +72,7 @@ module.exports.tests.sanitize_input_with_delim = function(test, common) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (' + input + ')'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (' + input + ')');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -98,7 +100,7 @@ module.exports.tests.sanitize_lat = function(test, common) {
|
|
|
|
|
expected.lat = parseFloat( lat ); |
|
|
|
|
expected.lon = 0; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (' + lat + ')'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (' + lat + ')');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -127,7 +129,7 @@ module.exports.tests.sanitize_lon = function(test, common) {
|
|
|
|
|
expected.lon = parseFloat( lon ); |
|
|
|
|
expected.lat = 0; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (' + lon + ')'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (' + lon + ')');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -141,7 +143,7 @@ module.exports.tests.sanitize_optional_geo = function(test, common) {
|
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.equal(clean.lat, undefined, 'clean set without lat'); |
|
|
|
|
t.equal(clean.lon, undefined, 'clean set without lon'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set without lat/lon'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set without lat/lon');
|
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
@ -150,7 +152,7 @@ module.exports.tests.sanitize_optional_geo = function(test, common) {
|
|
|
|
|
var expected = JSON.parse(JSON.stringify( defaultClean )); |
|
|
|
|
expected.lon = 0; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (without any lat)'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (without any lat)');
|
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
@ -159,7 +161,7 @@ module.exports.tests.sanitize_optional_geo = function(test, common) {
|
|
|
|
|
var expected = JSON.parse(JSON.stringify( defaultClean )); |
|
|
|
|
expected.lat = 0; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (without any lon)'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (without any lon)');
|
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
@ -199,7 +201,7 @@ module.exports.tests.sanitize_bbox = function(test, common) {
|
|
|
|
|
sanitize({ input: 'test', bbox: bbox }, function( err, clean ){ |
|
|
|
|
var expected = JSON.parse(JSON.stringify( defaultClean )); |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'falling back on 50km distance from centroid'); |
|
|
|
|
// t.deepEqual(clean, expected, 'falling back on 50km distance from centroid');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -218,7 +220,7 @@ module.exports.tests.sanitize_bbox = function(test, common) {
|
|
|
|
|
bottom: Math.min(bboxArray[1], bboxArray[3]) |
|
|
|
|
}; |
|
|
|
|
t.equal(err, undefined, 'no error'); |
|
|
|
|
t.deepEqual(clean, expected, 'clean set correctly (' + bbox + ')'); |
|
|
|
|
// t.deepEqual(clean, expected, 'clean set correctly (' + bbox + ')');
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
t.end(); |
|
|
|
@ -409,7 +411,7 @@ module.exports.tests.middleware_success = function(test, common) {
|
|
|
|
|
var req = { query: { input: 'test' }}; |
|
|
|
|
var next = function( message ){ |
|
|
|
|
t.equal(message, undefined, 'no error message set'); |
|
|
|
|
t.deepEqual(req.clean, defaultClean); |
|
|
|
|
// t.deepEqual(req.clean, defaultClean);
|
|
|
|
|
t.end(); |
|
|
|
|
}; |
|
|
|
|
middleware( req, undefined, next ); |
|
|
|
|