Skip to content

get/query by value #35

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

Merged
merged 2 commits into from
May 6, 2018
Merged

get/query by value #35

merged 2 commits into from
May 6, 2018

Conversation

lgandecki
Copy link
Collaborator

What:

get/query by value

Why:

as per discussion in #34

Note: setting .value on an element here somehow doesn't work, so i used .setAttribute. I linked it to my react project, and it worked with .value just fine. Not sure what's going on here.
I changed the selector part here to * instead of [${attribute}] to verify that that's not the cause:

return Array.from(container.querySelectorAll(`[${attribute}]`)).filter(node =>

but it didn't change anything.

Another note, related to that, in my original implementation in my project I used a selector for getting all inputs, I guess if someone set an attribute value on a div, current implementation would get that element as well - not sure how much we want to prevent such edge cases. It's a decision between complicating the code a bit, and making sure we treat values only when they are actually input values.

How:

Following the existing pattern

Checklist:

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

@codecov
Copy link

codecov bot commented May 6, 2018

Codecov Report

Merging #35 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #35   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           8      8           
  Lines         138    145    +7     
  Branches       34     35    +1     
=====================================
+ Hits          138    145    +7
Impacted Files Coverage Δ
src/queries.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cde0cdf...e211b14. Read the comment docs.

</div>
`)

getByPlaceholderText('lastname').setAttribute('value', 'Norris')
Copy link
Collaborator

@alexkrolick alexkrolick May 6, 2018

Choose a reason for hiding this comment

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

Might be a bit more straightforward to start out with the value in the DOM, since the setAttribute part is JSDOM's responsibility. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

makes sense, I updated the test.

@alexkrolick alexkrolick merged commit b41b2e7 into master May 6, 2018
@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@alexkrolick alexkrolick deleted the getByValue branch May 6, 2018 07:35
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.

3 participants