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