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

Fix .exists not accepting any EnzymeSelector #1934

Merged
merged 1 commit into from
Dec 11, 2018

Conversation

btimo
Copy link
Contributor

@btimo btimo commented Dec 10, 2018

.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 necessary TypeError.

@btimo btimo force-pushed the fix/exists-selector-component branch from a3568c0 to 6d30358 Compare December 10, 2018 12:37
`.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`.
@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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:

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it:

Am I missing something?

@ljharb ljharb merged commit b03e12e into enzymejs:master Dec 11, 2018
Make string selectors awesome automation moved this from Open to Closed/Merged Dec 11, 2018
@ljharb
Copy link
Member

ljharb commented Dec 11, 2018

Thanks for filing this! It's great to ensure consistency :-)

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

Successfully merging this pull request may close these issues.

None yet

2 participants