From f3b72106c4a3686f810902570f36ab84ea3c8739 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Wed, 23 Jan 2019 13:50:25 -0800 Subject: [PATCH] Add tests for node bindings. --- test/nodejs/route.js | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/nodejs/route.js b/test/nodejs/route.js index 011a098a3..9ad4276b7 100644 --- a/test/nodejs/route.js +++ b/test/nodejs/route.js @@ -606,3 +606,51 @@ test('route: route in Monaco without motorways', function(assert) { }); }); + +test('route: throws on invalid waypoints values needs at least two', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [0] + }; + assert.throws(function () { osrm.route(options, function (err, response) { }); }, + 'At least two waypoints must be provided'); +}); + +test('route: throws on invalid waypoints values, needs first and last coordinate indices', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [1, 2] + }; + assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, + 'First and last waypoints values must correspond to first and last coordinate indices'); +}); + +test('route: throws on invalid waypoints values, order matters', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [2, 0] + }; + assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, + 'First and last waypoints values must correspond to first and last coordinate indices'); +}); + +test('route: throws on invalid waypoints values, waypoints must correspond with a coordinate index', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [0, 3, 2] + }; + assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, + 'Waypoints must correspond with the index of an input coordinate'); +}); \ No newline at end of file