-
Notifications
You must be signed in to change notification settings - Fork 65
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
Handle elements in non-children props in shallow render #24
Conversation
Current coverage is 100% (diff: 100%)@@ master #24 diff @@
===================================
Files 3 3
Lines 38 46 +8
Methods 0 0
Messages 0 0
Branches 0 0
===================================
+ Hits 38 46 +8
Misses 0 0
Partials 0 0
|
Hi @stevoland, thanks for your contribution! Looks pretty neat, I can't review it properly right now, I'll have a look later this afternoon, sorry! |
obj[key] = nodeToJson(node[key]); | ||
}); | ||
|
||
return obj; |
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.
I would prefer that to use Object.entries
and reduce
:
return Object.entries(node).reduce((obj, [key, val]) => {
obj[key] = nodeToJson(val);
return obj;
}, {});
What do you think?
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.
cool, didn't know about object.entries
. will change
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.
fixed, thanks
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.
Ah sorry, tests are failing because Object.entries
is not available in Node v4. Can you use object.entries?
import entries from 'object.entries';
// ...
return entries(node).reduce(...
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.
done
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.
Nice
cc5458c
to
2bcc820
Compare
2bcc820
to
c542b80
Compare
Merged 🎉 Really nice @stevoland, thanks a lot for your contribution 👍 It will go in the next published release very soon. |
The change is published in |
I'm afraid you might want consider reverting this. I've just noticed that when testing react-native, a previous snapshot of:
is now
I'll try to fix this afternoon. Sorry :/ |
Ah crap, it might be a good thing to have React Native unit tests but I'm not sure how to do that as I'm not familiar with React Native. |
Should have a fix in an hour. I think using lodash |
This should fix it: #25 Sorry again! |
Currently React elements in props other than children aren't processed so snapshots will end up with
toString()
ed component types.This is a breaking change for those with existing snapshots of elements containing elements in non-children props.