|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
var sanitize = require('../../../sanitiser/_geo_reverse'); |
|
|
|
|
var defaults = require('../../../query/defaults'); |
|
|
|
|
|
|
|
|
|
module.exports.tests = {}; |
|
|
|
|
|
|
|
|
@ -54,6 +55,52 @@ module.exports.tests.sanitize_boundary_country = function(test, common) {
|
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('boundary.circle.lat/lon should be overridden with point.lat/lon', function(t) { |
|
|
|
|
var raw = { |
|
|
|
|
'point.lat': '12.121212', |
|
|
|
|
'point.lon': '21.212121', |
|
|
|
|
'boundary.circle.lat': '13.131313', |
|
|
|
|
'boundary.circle.lon': '31.313131' |
|
|
|
|
}; |
|
|
|
|
var clean = {}; |
|
|
|
|
var errorsAndWarnings = sanitize(raw, clean); |
|
|
|
|
|
|
|
|
|
t.equals(raw['boundary.circle.lat'], 12.121212, 'should be set to point.lat'); |
|
|
|
|
t.equals(raw['boundary.circle.lon'], 21.212121, 'should be set to point.lon'); |
|
|
|
|
t.equals(clean['boundary.circle.lat'], 12.121212, 'should be set to point.lat'); |
|
|
|
|
t.equals(clean['boundary.circle.lon'], 21.212121, 'should be set to point.lon'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('no boundary.circle.radius supplied should be set to default', function(t) { |
|
|
|
|
var raw = { |
|
|
|
|
'point.lat': '12.121212', |
|
|
|
|
'point.lon': '21.212121' |
|
|
|
|
}; |
|
|
|
|
var clean = {}; |
|
|
|
|
var errorsAndWarnings = sanitize(raw, clean); |
|
|
|
|
|
|
|
|
|
t.equals(raw['boundary.circle.radius'], defaults['boundary:circle:radius'], 'should be from defaults'); |
|
|
|
|
t.equals(clean['boundary.circle.radius'], parseFloat(defaults['boundary:circle:radius']), 'should be same as raw'); |
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('explicit boundary.circle.radius should be used instead of default', function(t) { |
|
|
|
|
var raw = { |
|
|
|
|
'point.lat': '12.121212', |
|
|
|
|
'point.lon': '21.212121', |
|
|
|
|
'boundary.circle.radius': '3248732857km' // this will never be the default
|
|
|
|
|
}; |
|
|
|
|
var clean = {}; |
|
|
|
|
var errorsAndWarnings = sanitize(raw, clean); |
|
|
|
|
|
|
|
|
|
t.equals(raw['boundary.circle.radius'], '3248732857km', 'should be parsed float'); |
|
|
|
|
t.equals(clean['boundary.circle.radius'], 3248732857.0, 'should be copied from raw'); |
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
module.exports.all = function (tape, common) { |
|
|
|
|