Skip to content

Commit

Permalink
Add nodejs binding test
Browse files Browse the repository at this point in the history
Signed-off-by: FILLAU Jean-Maxime <[email protected]>
  • Loading branch information
FILLAU Jean-Maxime authored and Patrick Niklaus committed May 30, 2017
1 parent 98ad9d8 commit 15a1e10
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/nodejs/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,48 @@ test('route: throws on bad radiuses', function(assert) {
}, function(err, route) {}) },
/Radiuses array must have the same length as coordinates array/);
});

test('route: routes Monaco with valid approaches values', function(assert) {
assert.plan(3);
var osrm = new OSRM(monaco_path);
var options = {
coordinates: two_test_coordinates,
approaches: [null, 'curb']
};
osrm.route(options, function(err, route) {
assert.ifError(err);
});
options.approaches = [null, null];
osrm.route(options, function(err, route) {
assert.ifError(err);
});
options.approaches = ['unrestricted', null];
osrm.route(options, function(err, route) {
assert.ifError(err);
});
});

test('route: throws on bad approaches', function(assert) {
assert.plan(4);
var osrm = new OSRM(monaco_path);
assert.throws(function() { osrm.route({
coordinates: two_test_coordinates,
approaches: 10
}, function(err, route) {}) },
/Approaches must be an arrays of strings/);
assert.throws(function() { osrm.route({
coordinates: two_test_coordinates,
approaches: ['curb']
}, function(err, route) {}) },
/Approaches array must have the same length as coordinates array/);
assert.throws(function() { osrm.route({
coordinates: two_test_coordinates,
approaches: ['curb', 'test']
}, function(err, route) {}) },
/'approaches' param must be one of \[curb, unrestricted\]/);
assert.throws(function() { osrm.route({
coordinates: two_test_coordinates,
approaches: [10, 15]
}, function(err, route) {}) },
/Approach must be a string: \[curb, unrestricted\] or null/);
});

0 comments on commit 15a1e10

Please sign in to comment.