-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into chore--vpat
- Loading branch information
Showing
10 changed files
with
1,465 additions
and
1,137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
import { JestAxe, configureAxe } from 'jest-axe'; | ||
|
||
const axe: JestAxe = configureAxe({ | ||
rules: { | ||
region: { enabled: false } | ||
} | ||
}); | ||
|
||
export default axe; |
1 change: 1 addition & 0 deletions
1
packages/react/__tests__/setupTests.js → packages/react/__tests__/setupTests.ts
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { JestAxe, configureAxe } from 'jest-axe'; | ||
|
||
const axe: JestAxe = configureAxe({ | ||
rules: { | ||
region: { enabled: false } | ||
} | ||
}); | ||
|
||
export default axe; |
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,78 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import Button from '../../../src/components/Button'; | ||
import Icon from '../../../src/components/Icon'; | ||
import axe from '../../axe'; | ||
|
||
test('should render primary button', () => { | ||
render( | ||
<> | ||
<Button>default primary</Button> | ||
<Button variant="primary">variant primary</Button> | ||
</> | ||
); | ||
expect(screen.getByRole('button', { name: 'default primary' })).toHaveClass( | ||
'Button--primary' | ||
); | ||
expect(screen.getByRole('button', { name: 'variant primary' })).toHaveClass( | ||
'Button--primary' | ||
); | ||
}); | ||
|
||
test('should render secondary button', () => { | ||
render(<Button variant="secondary">secondary</Button>); | ||
const SecondaryButton = screen.getByRole('button', { name: 'secondary' }); | ||
expect(SecondaryButton).toHaveClass('Button--secondary'); | ||
}); | ||
|
||
test('should render error button', () => { | ||
render(<Button variant="error">error</Button>); | ||
const ErrorButton = screen.getByRole('button', { name: 'error' }); | ||
expect(ErrorButton).toHaveClass('Button--error'); | ||
}); | ||
|
||
test('should render button as link', () => { | ||
render(<Button variant="link">link</Button>); | ||
const LinkButton = screen.getByRole('button', { name: 'link' }); | ||
expect(LinkButton).toHaveClass('Link'); | ||
}); | ||
|
||
test('should render button as tag', () => { | ||
render(<Button variant="tag">tag</Button>); | ||
const TagButton = screen.getByRole('button', { name: 'tag' }); | ||
expect(TagButton).toHaveClass('Tag'); | ||
}); | ||
|
||
test('should handle <Icon /> as child', () => { | ||
render( | ||
<Button> | ||
<Icon type="trash" /> | ||
Delete | ||
</Button> | ||
); | ||
const button = screen.getByRole('button', { name: 'Delete' }).firstChild; | ||
expect(button).toHaveClass('Icon--trash'); | ||
}); | ||
|
||
test('should handle "thin" modifier', () => { | ||
render(<Button thin>link</Button>); | ||
const button = screen.getByRole('button', { name: 'link' }); | ||
expect(button).toHaveClass('Button--thin'); | ||
}); | ||
|
||
test('should return no axe violations', async () => { | ||
const { container } = render( | ||
<> | ||
<Button>primary</Button> | ||
<Button variant="primary">primary</Button> | ||
<Button variant="link">link</Button> | ||
<Button> | ||
<Icon type="bolt" /> | ||
scan | ||
</Button> | ||
</> | ||
); | ||
|
||
const results = await axe(container); | ||
expect(results).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
Oops, something went wrong.