-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(a11y): ensure label is present for buttons in busy state
- Loading branch information
1 parent
9271d4e
commit a388e48
Showing
5 changed files
with
217 additions
and
170 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
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 |
---|---|---|
@@ -1,12 +1,47 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'vitest-axe'; | ||
import AccountCircle from '@jwp/ott-theme/assets/icons/account_circle.svg?react'; | ||
import 'vitest-axe/extend-expect'; | ||
|
||
import { renderWithRouter } from '../../../test/utils'; | ||
import Icon from '../Icon/Icon'; | ||
|
||
import Button from './Button'; | ||
|
||
describe('<Button>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render(<Button label="aa" active onClick={() => null} />); | ||
const { container } = renderWithRouter( | ||
<> | ||
<Button label="Default button" /> | ||
<Button label="Active button" active /> | ||
<Button label="Disabled button" disabled /> | ||
<Button label="Busy button" busy /> | ||
<Button label="Small button" size="small" /> | ||
<Button label="Large button" size="large" /> | ||
<Button label="Full width button" fullWidth /> | ||
<Button label="With start icon" startIcon={<Icon icon={AccountCircle} />} /> | ||
<Button label="Button link" to="https://jwplayer.com" /> | ||
</>, | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
test('WCAG 2.1 (AA) compliant', async () => { | ||
const { container } = renderWithRouter( | ||
<> | ||
<Button label="Default button" /> | ||
<Button label="Active button" active /> | ||
<Button label="Disabled button" disabled /> | ||
<Button label="Busy button" busy /> | ||
<Button label="Small button" size="small" /> | ||
<Button label="Large button" size="large" /> | ||
<Button label="Full width button" fullWidth /> | ||
<Button label="With start icon" startIcon={<Icon icon={AccountCircle} />} /> | ||
<Button label="Button link" to="https://jwplayer.com" fullWidth /> | ||
</>, | ||
); | ||
|
||
expect(await axe(container)).toHaveNoViolations(); | ||
}); | ||
}); |
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
Oops, something went wrong.