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

feat(queries): allow overriding queries in getQueriesForElement #67

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

alexkrolick
Copy link
Collaborator

@alexkrolick alexkrolick commented Jul 9, 2018

What:

Why:

How:

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

* @param {FuncMap|FuncMap[]} queries object of functions, or array of objects
* @returns {FuncMap} returns object of functions bound to container
*/
function getQueriesForElement(element, queries = defaultQueries) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that passing custom queries overrides the default instead of merging. If you want to merge you need to import queries and add it to the array, too.

Open to changing this but I think it makes sense; wrappers like react-testing-library's render can merge queries by default on top of this API if they prefer.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looks good! Just one feature I want removed.

*/
function getQueriesForElement(element, queries = defaultQueries) {
let flattenedQueries
if (Array.isArray(queries)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather not have this logic here. If someone wants to merge the built in queries they can be responsible for doing that themselves when they call the function.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Super!

@kentcdodds kentcdodds merged commit e0200af into testing-library:master Jul 9, 2018
@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

alexkrolick added a commit to alexkrolick/dom-testing-library that referenced this pull request Sep 13, 2018
* chore: document GitHub issues flow

* chore: Link to issues policy

* chore: update policies, badges

* minor updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants