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

feature: implement toHaveDisplayValue Jest matcher #1456

Closed
mdjastrzebski opened this issue Aug 17, 2023 · 1 comment · Fixed by #1463
Closed

feature: implement toHaveDisplayValue Jest matcher #1456

mdjastrzebski opened this issue Aug 17, 2023 · 1 comment · Fixed by #1463
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mdjastrzebski
Copy link
Member

mdjastrzebski commented Aug 17, 2023

Describe the Feature

toHaveDisplayValue is a Jest DOM matcher that asserts the value visible to the user in text inputs.

Adapting it to our case it would assert the value in TextInput host elements, to match given value.

Possible Implementations

Proposed API:

export function toHaveDisplayValue(
  this: jest.MatcherContext,
  element: ReactTestInstance,
  valueToMatch: TextMatch,
  options?: TextMatchOptions
)

The matcher should:

  1. Validate that it is invoked on host TextInput element
  2. Get the current value as props.value ?? props.defaultValue
  3. Compare it with passed valueToMatch.

Each matcher should have a fairly comprehensive test suite.

Links

Related Issues

#1454

@mdjastrzebski
Copy link
Member Author

🎉 Release in version: v12.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants