You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Test src/utils/mapNumberToRange.spec.ts:28:21 fails locally and expects the value to be 5, but it is actually 7.
To Reproduce
Steps to reproduce the behaviour:
Make sure you're using Node 18
Install dependencies
Execute npm run test
See the error
Expected behaviour
Tests should pass
Desktop (please complete the following information):
OS: Arch Linux 5.17
Browser: None (Node in a terminal)
Version: Node v18.13.0
Additional context
The test tests the behaviour of the mapNumberToRange function with a value smaller than the minimum value with the following code:
constval=-4constmin=0constmax=10constresults=mapNumberToRange({ val, min, max })expect(results).toBe(5)
The function itself does a check if the value is greater than the maximum value (in which case it calculates the value as val: val - (max + 1)) and another check to see if the value is smaller than the minimum value (in which case it calculates the value as val: val + (max + 1)).
Since the calculations for both cases only differ by a singular operation (- max vs + max), it does look sensible, so this might only be a typo or an artefact of an older version of the function. However, I could also imagine the calculation being meant as val: val + (min + 1) instead, which would result in a value of 0 (i.e. the minimum), which sounds less credible to me, given that a value greater than the maximum does not result in the maximum being returned either.
My guess is a typo, or am I missing something?
I'm happy to provide a fix here since I'm also working on a potential fix for #278, which I should be done with soonish.
The text was updated successfully, but these errors were encountered:
Describe the bug
Test
src/utils/mapNumberToRange.spec.ts:28:21
fails locally and expects the value to be5
, but it is actually7
.To Reproduce
Steps to reproduce the behaviour:
npm run test
Expected behaviour
Tests should pass
Desktop (please complete the following information):
Additional context
The test tests the behaviour of the
mapNumberToRange
function with a value smaller than the minimum value with the following code:The function itself does a check if the value is greater than the maximum value (in which case it calculates the value as
val: val - (max + 1)
) and another check to see if the value is smaller than the minimum value (in which case it calculates the value asval: val + (max + 1)
).Since the calculations for both cases only differ by a singular operation (
- max
vs+ max
), it does look sensible, so this might only be a typo or an artefact of an older version of the function. However, I could also imagine the calculation being meant asval: val + (min + 1)
instead, which would result in a value of0
(i.e. the minimum), which sounds less credible to me, given that a value greater than the maximum does not result in the maximum being returned either.My guess is a typo, or am I missing something?
I'm happy to provide a fix here since I'm also working on a potential fix for #278, which I should be done with soonish.
The text was updated successfully, but these errors were encountered: