-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaN handling #21
NaN handling #21
Conversation
Thanks for the contribution! |
@@ -84,4 +84,15 @@ describe('immutableStateInvariantMiddleware', () => { | |||
dispatch({type: 'SOME_ACTION', x}); | |||
}).toNotThrow(); | |||
}); | |||
|
|||
it('works correctly with NaN', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these tests into the proper file? Since this is a change made in trackForMutations.js
, the place to write tests for it is /test/trackForMutations.spec.js
. Also, take a look there that we have the tests cases in an object that describes them, both for mutations and for non mutations. You should add an entry to the nonMutations object here: https://github.com/matthieu-foucault/redux-immutable-state-invariant/blob/b21595635a88d3c4e8223f2bb7203c140415fb72/test/trackForMutations.spec.js#L175
Great, thanks for your contribution again! Merging this |
Yeah!!! Thank you for this commit! |
Although it's rare, you can end up with a NaN in your state if it's the output of a mathematical function.
NaN is tricky:
NaN === NaN; // false
Number.NaN === NaN; // false
Number.isNaN(NaN); // true
This PR prevents the middleware from throwing if there is a NaN in the state