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.
|
|
|
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
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var res = {
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
center_point: {
|
|
|
|
lat: 40,
|
|
|
|
lon: -71
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
var expected = 742.348;
|
|
|
|
distance(req, res, function () {
|
|
|
|
t.equal(res.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);
|
|
|
|
}
|
|
|
|
};
|