Skip to content

Commit

Permalink
modify test
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Sep 17, 2024
1 parent d6dc829 commit a475aa7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/mui-material/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,21 +881,17 @@ describe('<Modal />', () => {
}).not.toErrorDev();
});

it('should not override default onKeyDown', () => {
it('should not override default onKeyDown', async () => {
const handleKeyDown = spy();
const handleClose = spy();
const { getByTestId } = render(

const { user } = render(
<Modal open onKeyDown={handleKeyDown} onClose={handleClose}>
<div data-testid="modal" tabIndex={-1} />
<div tabIndex={-1} />
</Modal>,
);
act(() => {
getByTestId('modal').focus();
});

fireEvent.keyDown(getByTestId('modal'), {
key: 'Escape',
});
await user.keyboard('{Escape}');

expect(handleKeyDown).to.have.property('callCount', 1);
expect(handleClose).to.have.property('callCount', 1);
Expand Down

0 comments on commit a475aa7

Please sign in to comment.