From 01317ae2f02b7f280d3ed0a162edfac0461e9a6a Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Fri, 12 Jul 2024 22:27:01 +0300 Subject: [PATCH] chore: add test for eta calculations --- calcs/eta.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/calcs/eta.js b/calcs/eta.js index 4f0c0bb..3f43a70 100644 --- a/calcs/eta.js +++ b/calcs/eta.js @@ -18,9 +18,7 @@ module.exports = function (app) { } var datems = date.getTime() - var timetopoint = Math.floor( - distance / velocityMadeGood * 1000 - ) + var timetopoint = Math.floor(distance / velocityMadeGood * 1000) // app.debug(`Using datetime: ${date} ms to point : ${timetopoint} currentms: ${datems}`) var etams = datems + timetopoint @@ -50,6 +48,26 @@ module.exports = function (app) { value: eta } ] - } + }, + tests: [ + { + input: ['2024-07-12T18:00:00Z', 1000, 2], + expected: [ + { + path: + 'navigation.courseGreatCircle.nextPoint.estimatedTimeOfArrival', + value: '2024-07-12T18:08:20.000Z' + }, + { + path: 'navigation.courseGreatCircle.nextPoint.timeToGo', + value: 500 + }, + { + path: 'navigation.courseGreatCircle.nextPoint.eta', + value: '2024-07-12T18:08:20.000Z' + } + ] + } + ] } }