-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve AutoComplete tests and stories
- Loading branch information
1 parent
93fbb66
commit fbeb925
Showing
3 changed files
with
496 additions
and
82 deletions.
There are no files selected for viewing
34 changes: 25 additions & 9 deletions
34
packages/fuselage/src/components/AutoComplete/AutoComplete.spec.tsx
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,18 +1,34 @@ | ||
import { composeStories } from '@storybook/testing-react'; | ||
import { render } from '@testing-library/react'; | ||
import { axe } from 'jest-axe'; | ||
import React from 'react'; | ||
import { withResizeObserverMock } from 'testing-utils/mocks/withResizeObserverMock'; | ||
|
||
import { AutoComplete } from '.'; | ||
import * as stories from './AutoComplete.stories'; | ||
|
||
const testCases = Object.values(composeStories(stories)).map((Story) => [ | ||
Story.storyName || 'Story', | ||
Story, | ||
]); | ||
|
||
withResizeObserverMock(); | ||
|
||
it('renders without crashing', () => { | ||
render( | ||
<AutoComplete | ||
filter='' | ||
value={[]} | ||
renderItem={() => null} | ||
onChange={jest.fn()} | ||
/> | ||
describe('[AutoComplete Rendering]', () => { | ||
test.each(testCases)( | ||
`renders %s without crashing`, | ||
async (_storyname, Story) => { | ||
const tree = render(<Story />); | ||
expect(tree.baseElement).toMatchSnapshot(); | ||
} | ||
); | ||
|
||
test.each(testCases)( | ||
'%s should have no a11y violations', | ||
async (_storyname, Story) => { | ||
const { container } = render(<Story />); | ||
|
||
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.