-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// TODO remove when we can upgrade to @testing-library/user-event:14, which currently does not work in this test | ||
/* eslint-disable @typescript-eslint/await-thenable */ | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { Select } from './index'; | ||
|
||
describe('<Select />', () => { | ||
it('renders and calls onChange', async () => { | ||
const onChange = jest.fn(); | ||
|
||
const valueA = 'a'; | ||
const labelA = 'some label for a'; | ||
const optionA = { value: valueA, label: labelA }; | ||
render(<Select options={[optionA, { value: 'b' }]} onChange={onChange} />); | ||
|
||
await userEvent.click(screen.getByRole('combobox')); | ||
await userEvent.click(screen.getByText(labelA)); | ||
expect(onChange).toHaveBeenCalledWith(valueA, optionA); | ||
}); | ||
}); |
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