Skip to content
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

Merged
merged 3 commits into from
Oct 3, 2016
Merged

NaN handling #21

merged 3 commits into from
Oct 3, 2016

Conversation

matthieu-foucault
Copy link
Contributor

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

@coveralls
Copy link

coveralls commented Sep 23, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling b215956 on matthieu-foucault:NaN_handling into 3a2c647 on leoasis:master.

@leoasis
Copy link
Owner

leoasis commented Sep 27, 2016

Thanks for the contribution!

@@ -84,4 +84,15 @@ describe('immutableStateInvariantMiddleware', () => {
dispatch({type: 'SOME_ACTION', x});
}).toNotThrow();
});

it('works correctly with NaN', () => {
Copy link
Owner

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

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling dd32c34 on matthieu-foucault:NaN_handling into 3a2c647 on leoasis:master.

@leoasis
Copy link
Owner

leoasis commented Oct 3, 2016

Great, thanks for your contribution again! Merging this

@leoasis leoasis merged commit 784c966 into leoasis:master Oct 3, 2016
@matthieu-foucault matthieu-foucault deleted the NaN_handling branch October 4, 2016 18:58
@asakasinsky
Copy link

Yeah!!! Thank you for this commit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants