|
|
@ -206,75 +206,6 @@ module.exports.tests.sanitize_bounding_rect = function(test, common) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.sanitize_viewport = function(test, common) { |
|
|
|
|
|
|
|
test('valid viewport', function(t) { |
|
|
|
|
|
|
|
var req = { |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
text: 'test', |
|
|
|
|
|
|
|
'focus.viewport.min_lat': '37', |
|
|
|
|
|
|
|
'focus.viewport.max_lat': '38', |
|
|
|
|
|
|
|
'focus.viewport.min_lon': '-123', |
|
|
|
|
|
|
|
'focus.viewport.max_lon': '-122' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
sanitize(req, function() { |
|
|
|
|
|
|
|
t.equal(req.errors[0], undefined, 'no error'); |
|
|
|
|
|
|
|
t.equal(req.clean['focus.viewport.min_lat'], parseFloat(req.query['focus.viewport.min_lat']), 'correct min_lat in clean'); |
|
|
|
|
|
|
|
t.equal(req.clean['focus.viewport.max_lat'], parseFloat(req.query['focus.viewport.max_lat']), 'correct max_lat in clean'); |
|
|
|
|
|
|
|
t.equal(req.clean['focus.viewport.min_lon'], parseFloat(req.query['focus.viewport.min_lon']), 'correct min_lon in clean'); |
|
|
|
|
|
|
|
t.equal(req.clean['focus.viewport.max_lon'], parseFloat(req.query['focus.viewport.max_lon']), 'correct max_lon in clean'); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('error returned if focus.point and focus.viewpoint specified', function(t) { |
|
|
|
|
|
|
|
var req = { |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
text: 'test', |
|
|
|
|
|
|
|
'focus.point.lat': '10', |
|
|
|
|
|
|
|
'focus.point.lon': '15', |
|
|
|
|
|
|
|
'focus.viewport.min_lat': '37', |
|
|
|
|
|
|
|
'focus.viewport.max_lat': '38', |
|
|
|
|
|
|
|
'focus.viewport.min_lon': '-123', |
|
|
|
|
|
|
|
'focus.viewport.max_lon': '-122' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sanitize(req, function() { |
|
|
|
|
|
|
|
t.equal(req.errors[0], 'focus.point and focus.viewport can\'t both be set', 'no error'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.min_lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.max_lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.min_lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.max_lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.point.lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.point.lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('error returned if focus.point and focus.viewpoint partially specified', function(t) { |
|
|
|
|
|
|
|
var req = { |
|
|
|
|
|
|
|
query: { |
|
|
|
|
|
|
|
text: 'test', |
|
|
|
|
|
|
|
'focus.point.lat': '10', |
|
|
|
|
|
|
|
'focus.viewport.min_lat': '37', |
|
|
|
|
|
|
|
'focus.viewport.max_lon': '-122' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sanitize(req, function() { |
|
|
|
|
|
|
|
t.equal(req.errors[0], 'focus.point and focus.viewport can\'t both be set', 'no error'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.min_lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.max_lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.min_lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.viewport.max_lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.point.lat'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.notOk(req.clean.hasOwnProperty('focus.point.lon'), 'clean should be empty'); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.tests.sanitize_size = function(test, common) { |
|
|
|
module.exports.tests.sanitize_size = function(test, common) { |
|
|
|
test('invalid size value', function(t) { |
|
|
|
test('invalid size value', function(t) { |
|
|
|
var req = { query: { size: 'a', text: 'test', lat: 0, lon: 0 } }; |
|
|
|
var req = { query: { size: 'a', text: 'test', lat: 0, lon: 0 } }; |
|
|
|