Open
Description
Describe the feature you'd like:
Add a matcher for aria-pressed for checking button toggle states.
Suggested implementation:
A new matcher called toBePressed
Describe alternatives you've considered:
An alternative solution would be to check for the attribute aria-pressed="true"
or aria-pressed="mixed"
Teachability, Documentation, Adoption, Migration Strategy:
Docs entry:
toBePressed
toBePressed()
This allows you to check if a form element is currently pressed.
An element is pressed if it is a button having a aria-pressed="true"
or aria-pressed="mixed"
attribute.
Examples
<button data-testid="pressed-button" aria-pressed="true" />
<input data-testid="pressed-input" type="button" aria-pressed="true" />
<div data-testid="pressed-div" role="button" tabindex="0" aria-pressed="true" />
<button data-testid="pressed-button-mixed" aria-pressed="mixed" />
expect(getByTestId('pressed-button')).toBePressed()
expect(getByTestId('pressed-input')).toBePressed()
expect(getByTestId('pressed-div')).toBePressed()
expect(getByTestId('pressed-button-mixed')).toBePressed()