-
-
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
Make .exists
take optional selector
#1695
Conversation
.exists
take optional selector
5207bb7
to
1d801c1
Compare
Thanks for the PR - I'm not sure if this complexity is worth adding to the API, since |
I'm not sure either, and I very much appreciate the lean API and the effort that went into keeping it lean, so I'm rather happy you're hesitating. Here are some arguments, ordered from crappy to somewhat good, why I'd still like to see this change included in Enzyme;
And that last sob story is of course what prompted this PR. Now the question is just whether the story is sad enough! :) |
If |
Oh, very good question! Hmm. Not sure. Preventing the misunderstanding was definitely my main intent, so if an error had saved me from blowing my client's face off I probably wouldn't have made this PR. The crappy parts of the arguments still stand however, and I think my immediate reaction to an error saying "Exists doesn't take an argument" would be "well, why the hell not". As a very unscientific and solitaire data point; in our current fledgling project we have 18 uses of My answer to your question: Yes, I'd still want this proposed API, but not as badly, and would be happy to rework the PR to make |
1d801c1
to
7fcd96e
Compare
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 bearing with me; I think I'm convinced. I made a few small tweaks, and rebased, and will merge shortly.
Ah, good catch adding the default arg! |
.exists, since [enzymejs#1695](enzymejs#1695), accepts a 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`.
`.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`.
`.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`.
`.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`.
This PR makes
.exists
optionally take a selector, in which case it will delegate to.find(selector).exists()
.