-
Notifications
You must be signed in to change notification settings - Fork 471
feat(queryByCurrentValue) #169
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
kentcdodds
merged 16 commits into
testing-library:master
from
eunjae-lee:pr/get_by_current_value
Dec 12, 2018
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6f596d6
feat(queryByCurrentValue): add get/query by current value
eunjae-lee 4ae8c95
feat(queryByCurrentValue): exports (query|get)AllByCurrentValue
eunjae-lee 633028c
chore: change the order of exports
eunjae-lee 74fcf1b
fix: add implementation for `select` element at `queryAllByCurrentValue`
eunjae-lee 82f1aa0
chore: add tests for get/queryByCurrentValue
eunjae-lee eb60b8f
chore: add test for getAllByCurrentValue to throw
eunjae-lee 4a88328
chore: rename xxxByCurrentValue -> xxxByDisplayValue
eunjae-lee f941225
docs: add `getByDisplayValue`
eunjae-lee 0ef11c9
docs: add `eunjae-lee` as a contributor
eunjae-lee c960865
docs: remove `getByAltText`, `getByTitle` and `getByValue`
eunjae-lee 4d3fe95
docs: update `getByDisplayValue`
eunjae-lee 661f194
chore: add test for 100% coverage
eunjae-lee d93ff6a
docs: remove unnecessary `console.log(...)`
eunjae-lee 1d05d51
Revert "docs: remove `getByAltText`, `getByTitle` and `getByValue`"
eunjae-lee d86856d
docs: remove `getBySelectText` and `getByValue`
eunjae-lee e5edb46
docs: update description on `getByDisplayName`
eunjae-lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if it's at all confusing that we are expected to set the
value
toAL
but when we use the query we search forAlabama
.I realize that's just how things work (the value for a select has a display value), but I feel like this could be a point of confusion for people. My guess is they'd prefer to select by
AL
instead which isn't what is shown to the user but feels more intuitive here. I'm not sure of the best solution to this... Maybe allow for either the display value or the actual value?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.
That makes sense. To end-users
Alabama
is a value, butAL
is the actual value.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.
However,
selectElem.value
could be either1
,AL
, or whatever user cannot know. In a perspective of writing tests as user would use it, I'd rather choose to restrict it to display value.What do you think?
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.
Hmm. To really avoid confusion, this could be called
getByDisplayValue()
.Technically an aria-menu is also compliant with this API: https://w3c.github.io/aria/#menu, https://w3c.github.io/aria/#aria-selected. In the ARIA case there doesn't seem to be any way to have a different "secret form value" vs "display value".EDIT: out of scopeThere 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.
Yeah, I think
displayValue
is probably a better mental model, though it may be a tiny confusing forinput
andtextarea
where the display value is actually the actual value but I think that's alright. Besides, people should normally be getting these elements by their label anyway, so I'm not too concerned about this slightly less-awesome API.Let's go with
getByDisplayValue
👍