From 15a1e104878c2d8dead872d508266fe9b0643f01 Mon Sep 17 00:00:00 2001 From: FILLAU Jean-Maxime Date: Tue, 30 May 2017 11:29:31 +0200 Subject: [PATCH] Add nodejs binding test Signed-off-by: FILLAU Jean-Maxime --- test/nodejs/route.js | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/nodejs/route.js b/test/nodejs/route.js index d3705ecaa..cc5e4bafe 100644 --- a/test/nodejs/route.js +++ b/test/nodejs/route.js @@ -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/); +}); \ No newline at end of file