-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `role = "progressbar"`: I've found some examples online where spinner is represented as a indeterminate progress bar. For example, [Material does this](https://m2.material.io/components/progress-indicators): ![image](https://github.com/user-attachments/assets/70a6908f-52ba-4646-8976-4ec21dec6f3e) ![image](https://github.com/user-attachments/assets/ad33b8d2-cf0f-4586-a35c-4a305048b141) - `aria-polite`: we don't need changes announcements to be assertive. - `aria-busy`: to express that content is being loaded: ![image](https://github.com/user-attachments/assets/e0378615-a03c-46fd-aa39-7481a8cc2812)
- Loading branch information
1 parent
85fcb31
commit 5267ad5
Showing
3 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import {Spinner} from '..'; | ||
import {render, screen} from '@testing-library/react'; | ||
import ThemeContextProvider from '../theme-context-provider'; | ||
import {makeTheme} from './test-utils'; | ||
|
||
test('spinner is accessible', () => { | ||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<Spinner /> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const spinner = screen.getByRole('progressbar', {name: 'Cargando'}); | ||
|
||
expect(spinner).toBeInTheDocument(); | ||
expect(spinner).toHaveAttribute('aria-busy'); | ||
}); | ||
|
||
test('spinner with aria-hidden is not visible', () => { | ||
render( | ||
<ThemeContextProvider theme={makeTheme()}> | ||
<Spinner aria-hidden /> | ||
</ThemeContextProvider> | ||
); | ||
|
||
const spinner = screen.queryByRole('progressbar'); | ||
|
||
expect(spinner).not.toBeInTheDocument(); | ||
}); |
This file contains 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 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