Skip to content

Commit

Permalink
fix: null handling in setDrift.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Jul 27, 2024
1 parent 563a083 commit 1ff3e04
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions calcs/setDrift.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
]
}
]
}
}

0 comments on commit 1ff3e04

Please sign in to comment.