mirror of https://github.com/pelias/api.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.8 KiB
55 lines
1.8 KiB
9 years ago
|
var sanitize = require('../../../sanitiser/_geo_common');
|
||
|
|
||
|
module.exports.tests = {};
|
||
|
|
||
|
module.exports.tests.interface = function(test, common) {
|
||
|
test('valid interface', function(t) {
|
||
|
t.equal(typeof sanitize.sanitize_bbox, 'function', 'sanitize_bbox is a valid function');
|
||
|
t.equal(typeof sanitize.sanitize_coord, 'function', 'sanitize_coord is a valid function');
|
||
|
t.equal(typeof sanitize.sanitize_boundary_circle, 'function', 'sanitize_boundary_circle is a valid function');
|
||
|
t.end();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
module.exports.tests.sanitize = function(test, common) {
|
||
|
test('valid circle trio', function (t) {
|
||
|
var clean = {};
|
||
|
var params = {
|
||
|
'boundary.circle.lat': 11,
|
||
|
'boundary.circle.lon': 22,
|
||
|
'boundary.circle.radius': 33
|
||
|
};
|
||
|
var is_required = true;
|
||
|
var all_required = true;
|
||
|
|
||
|
sanitize.sanitize_boundary_circle(clean, params, is_required, all_required);
|
||
|
t.equal(clean.boundary_circle_lat, params['boundary.circle.lat'], 'lat approved');
|
||
|
t.equal(clean.boundary_circle_lon, params['boundary.circle.lon'], 'lon approved');
|
||
|
t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved');
|
||
|
t.end();
|
||
|
});
|
||
|
test('valid circle, radius only, all not required', function (t) {
|
||
|
var clean = {};
|
||
|
var params = {
|
||
|
'boundary.circle.radius': 33
|
||
|
};
|
||
|
var is_required = true;
|
||
|
var all_required = false;
|
||
|
|
||
|
sanitize.sanitize_boundary_circle(clean, params, is_required, all_required);
|
||
|
t.equal(clean.boundary_circle_radius, params['boundary.circle.radius'], 'radius approved');
|
||
|
t.end();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
module.exports.all = function (tape, common) {
|
||
|
|
||
|
function test(name, testFunction) {
|
||
|
return tape('SANITIZER _geo_common ' + name, testFunction);
|
||
|
}
|
||
|
|
||
|
for( var testCase in module.exports.tests ){
|
||
|
module.exports.tests[testCase](test, common);
|
||
|
}
|
||
|
};
|