-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix .exists not accepting any EnzymeSelector #1934
Conversation
a3568c0
to
6d30358
Compare
`.exists`, since [enzymejs#1695](enzymejs#1695), accepts an optional selector. Unfortunately, this optional parameter was limited to the `string` type whereas the documentation inform us it can be any valid [EnzymeSelector](https://airbnb.io/enzyme/docs/api/selector.html). This commit fixes this limitation by accepting any type for the parameter and using `.find()` internal functions to throw any necessary `TypeError`.
6d30358
to
b03e12e
Compare
@@ -1073,14 +1073,11 @@ class ReactWrapper { | |||
* Returns true if the current wrapper has nodes. False otherwise. | |||
* If called with a selector it returns `.find(selector).exists()` instead. | |||
* | |||
* @param {String|Function} selector (optional) | |||
* @param {String|Function|Object} selector (optional) |
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.
The signature for find
is * @param {String|Function} selector
- should that be changed, or should this one stay the same?
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.
Not sure about what you're asking:
- I changed
find
signature to* @param {String|Function|Object} selector
- Internally,
find
will use theselector
with functions that accepts{String|Function|Object}
EnzymeSelector
andfind
documentation show that you can call it with anObject
:
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 mean that the jsdoc comment for find
in both ShallowWrapper and ReactWrapper say "string or function" - so it seems like it should be "string or function or object" as well
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.
Thanks for filing this! It's great to ensure consistency :-) |
.exists
, since #1695, accepts an optional selector.Unfortunately, this optional parameter was limited to the
string
type whereas the documentation inform us it can be any valid EnzymeSelector.This commit fixes this limitation by accepting any type for the parameter and using
.find()
internal functions to throw any necessaryTypeError
.