diff --git a/calcs/courseOverGroundMagnetic.js b/calcs/courseOverGroundMagnetic.js index f79bf3b..aa8c8f3 100644 --- a/calcs/courseOverGroundMagnetic.js +++ b/calcs/courseOverGroundMagnetic.js @@ -15,9 +15,9 @@ module.exports = function (app, plugin) { magneticVariation = app.getSelfPath( 'navigation.magneticVariation.value' ) - if (_.isUndefined(magneticVariation)) { - return - } + } + if (_.isUndefined(magneticVariation) || magneticVariation === null) { + return } if ( _.isUndefined(courseOverGroundTrue) || @@ -46,6 +46,9 @@ module.exports = function (app, plugin) { { input: [null, -0.01], expected: [{ path: 'navigation.courseOverGroundMagnetic', value: null }] + }, + { + input: [0.2, null] } ] } diff --git a/calcs/courseOverGroundTrue.js b/calcs/courseOverGroundTrue.js index e520bb9..266adbb 100644 --- a/calcs/courseOverGroundTrue.js +++ b/calcs/courseOverGroundTrue.js @@ -15,9 +15,9 @@ module.exports = function (app, plugin) { magneticVariation = app.getSelfPath( 'navigation.magneticVariation.value' ) - if (_.isUndefined(magneticVariation)) { - return - } + } + if (_.isUndefined(magneticVariation) || magneticVariation === null) { + return } if ( _.isUndefined(courseOverGroundMagnetic) || @@ -39,6 +39,9 @@ module.exports = function (app, plugin) { { input: [null, 0.01], expected: [{ path: 'navigation.courseOverGroundTrue', value: null }] + }, + { + input: [0.2, null] } ] } diff --git a/calcs/headingTrue.js b/calcs/headingTrue.js index 946ebb6..9eb1972 100644 --- a/calcs/headingTrue.js +++ b/calcs/headingTrue.js @@ -12,9 +12,9 @@ module.exports = function (app, plugin) { magneticVariation = app.getSelfPath( 'navigation.magneticVariation.value' ) - if (_.isUndefined(magneticVariation)) { - return - } + } + if (_.isUndefined(magneticVariation) || magneticVariation === null) { + return } if (_.isUndefined(heading) || heading === null) { return [{ path: 'navigation.headingTrue', value: null }] @@ -31,6 +31,9 @@ module.exports = function (app, plugin) { { input: [null, 0.01], expected: [{ path: 'navigation.headingTrue', value: null }] + }, + { + input: [0.2, null] } ] } diff --git a/calcs/setDrift.js b/calcs/setDrift.js index 26a4d5a..146a5c9 100644 --- a/calcs/setDrift.js +++ b/calcs/setDrift.js @@ -52,7 +52,7 @@ module.exports = function (app, plugin) { } var setTrue = setMagnetic + magneticVariation - if (_.isUndefined(magneticVariation)) { + if (_.isUndefined(magneticVariation) || magneticVariation === null) { setTrue = null } else if (setTrue >= 2 * Math.Pi) { setTrue = setTrue - Math.PI * 2 @@ -65,6 +65,22 @@ module.exports = function (app, plugin) { { path: 'environment.current.setTrue', value: setTrue }, { path: 'environment.current.setMagnetic', value: setMagnetic } ] - } + }, + tests: [ + { + input: [0.1, 0.2, 5, 4.5, null], + expected: [ + { path: 'environment.current.drift', value: 0.6890664427243886 }, + { + path: 'environment.current.setTrue', + value: null + }, + { + path: 'environment.current.setMagnetic', + value: 3.0482899952302343 + } + ] + } + ] } } diff --git a/calcs/windDirectionMagnetic.js b/calcs/windDirectionMagnetic.js index 986f737..ed7ee81 100644 --- a/calcs/windDirectionMagnetic.js +++ b/calcs/windDirectionMagnetic.js @@ -8,7 +8,7 @@ module.exports = function (app, plugin) { 'navigation.magneticVariation' ], calculator: function (directionTrue, magneticVariation) { - if (directionTrue === null) { + if (directionTrue === null || magneticVariation === null) { return [{ path: 'environment.wind.directionMagnetic', value: null }] } var directionMagnetic = directionTrue - magneticVariation @@ -25,6 +25,10 @@ module.exports = function (app, plugin) { { input: [null, -0.01], expected: [{ path: 'environment.wind.directionMagnetic', value: null }] + }, + { + input: [0.2, null], + expected: [{ path: 'environment.wind.directionMagnetic', value: null }] } ] }