From 5f494de7017d64b3abe321bb3d55f4684f5fae33 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Thu, 24 Jan 2019 14:11:09 -0800 Subject: [PATCH] More tests for waypoints. --- test/nodejs/match.js | 24 ++++++++++++++++++++++++ test/nodejs/route.js | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/test/nodejs/match.js b/test/nodejs/match.js index da4d7853b..3161060e9 100644 --- a/test/nodejs/match.js +++ b/test/nodejs/match.js @@ -319,6 +319,30 @@ test('match: throws on invalid waypoints values, waypoints must correspond with 'Waypoints must correspond with the index of an input coordinate'); }); +test('match: throws on invalid waypoints values, waypoints must be an array', function (assert) { + assert.plan(1); + var osrm = new OSRM(data_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: "string" + }; + assert.throws(function () { osrm.match(options, function (err, response) { console.log(err); }); }, + 'Waypoints must be an array of integers corresponding to the input coordinates.'); +}); + +test('match: throws on invalid waypoints values, waypoints must be an array of integers', function (assert) { + assert.plan(1); + var osrm = new OSRM(data_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [0,1,"string"] + }; + assert.throws(function () { osrm.match(options, function (err, response) { console.log(err); }); }, + 'Waypoint values must be an array of integers'); +}); + test('match: error on split trace', function(assert) { assert.plan(1); var osrm = new OSRM(data_path); diff --git a/test/nodejs/route.js b/test/nodejs/route.js index 9ad4276b7..bef370d75 100644 --- a/test/nodejs/route.js +++ b/test/nodejs/route.js @@ -653,4 +653,28 @@ test('route: throws on invalid waypoints values, waypoints must correspond with }; assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, 'Waypoints must correspond with the index of an input coordinate'); +}); + +test('route: throws on invalid waypoints values, waypoints must be an array', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: "string" + }; + assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, + 'Waypoints must be an array of integers corresponding to the input coordinates.'); +}); + +test('route: throws on invalid waypoints values, waypoints must be an array of integers', function (assert) { + assert.plan(1); + var osrm = new OSRM(monaco_path); + var options = { + steps: true, + coordinates: three_test_coordinates, + waypoints: [0,1,"string"] + }; + assert.throws(function () { osrm.route(options, function (err, response) { console.log(err); }); }, + 'Waypoint values must be an array of integers'); }); \ No newline at end of file