-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(TextInput): fix
handleAdditionalContentClick
handler (#1558)
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 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
32 changes: 32 additions & 0 deletions
32
src/components/controls/TextInput/__tests__/AdditionalContent.test.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
|
||
import userEvent from '@testing-library/user-event'; | ||
|
||
import {render, screen} from '../../../../../test-utils/utils'; | ||
import {Button} from '../../../Button'; | ||
import {Sheet} from '../../../Sheet'; | ||
import {TextInput} from '../TextInput'; | ||
|
||
const TextInputWithButtonAndSheet = () => { | ||
const [open, setOpen] = React.useState(false); | ||
const startContent = ( | ||
<React.Fragment> | ||
<Button onClick={() => setOpen(true)}>Open</Button> | ||
<Sheet visible={open}>Sheet content</Sheet> | ||
</React.Fragment> | ||
); | ||
return <TextInput startContent={startContent} />; | ||
}; | ||
|
||
describe('TextInput additional content', () => { | ||
test('TextInput should not be focused', async () => { | ||
render(<TextInputWithButtonAndSheet />); | ||
const user = userEvent.setup(); | ||
const button = await screen.findByText('Open'); | ||
await user.click(button); | ||
const sheetContent = await screen.findByText('Sheet content'); | ||
await user.click(sheetContent); | ||
const input = screen.getByRole('textbox'); | ||
expect(input).not.toHaveFocus(); | ||
}); | ||
}); |