-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix finding forwardRef itself #1684
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
Changes from all commits
5d037c2
704a600
9c6bcb2
eafaed6
43c32d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { | |
| childrenOfNode, | ||
| hasClassName, | ||
| } from './RSTTraversal'; | ||
| import { nodeHasType, propsOfNode } from './Utils'; | ||
| import { nodeHasType, propsOfNode, typeOf, ForwardRef } from './Utils'; | ||
| // our CSS selector parser instance | ||
| const parser = createParser(); | ||
|
|
||
|
|
@@ -227,6 +227,12 @@ export function buildPredicate(selector) { | |
| if (hasUndefinedValues) { | ||
| throw new TypeError('Enzyme::Props can’t have `undefined` values. Try using ‘findWhere()’ instead.'); | ||
| } | ||
| // the selector could also be a forwardRef | ||
| if (typeOf(selector) === ForwardRef) { | ||
| // re-build the predicate based on what is wrapped by forwardRef | ||
| // rather than the forwardRef itself | ||
| return buildPredicate(selector.render().props); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the right way to do this but maybe i'm misunderstanding. We should copy waht react-test-renderer does and this code should go in the react-16-adapter
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'm not sure either. Maybe the root cause of this is that enzyme is not generating a corresponding element for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah the selector module is used for all adapters, so the node type should be opaque in this module. |
||
| } | ||
| return node => nodeMatchesObjectProps(node, selector); | ||
| } | ||
| throw new TypeError('Enzyme::Selector does not support an array, null, or empty object as a selector'); | ||
|
|
||
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.
should use
react-is