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.
42 lines
889 B
42 lines
889 B
9 years ago
|
var distance = require('../../../middleware/distance')();
|
||
|
|
||
|
module.exports.tests = {};
|
||
|
|
||
|
module.exports.tests.computeDistance = function(test, common) {
|
||
|
test('valid lat/lon and results', function(t) {
|
||
|
var req = {
|
||
|
clean: {
|
||
|
lat: 45,
|
||
|
lon: -77
|
||
|
},
|
||
|
results: {
|
||
|
data: [
|
||
|
{
|
||
|
center_point: {
|
||
|
lat: 40,
|
||
|
lon: -71
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var expected = 742.348;
|
||
|
distance(req, null, function () {
|
||
|
t.equal(req.results.data[0].distance, expected, 'correct distance computed');
|
||
|
t.end();
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
|
||
|
module.exports.all = function (tape, common) {
|
||
|
|
||
|
function test(name, testFunction) {
|
||
|
return tape('[middleware] distance: ' + name, testFunction);
|
||
|
}
|
||
|
|
||
|
for( var testCase in module.exports.tests ){
|
||
|
module.exports.tests[testCase](test, common);
|
||
|
}
|
||
|
};
|