Skip to content

Commit 81ccc92

Browse files
committed
test: update onKeyDown tests in ListBox to use user-event for better simulation
1 parent 0c8979b commit 81ccc92

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/react-aria-components/test/ListBox.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,15 +1863,15 @@ describe('ListBox', () => {
18631863
});
18641864

18651865
describe('onKeyDown', () => {
1866-
it('should call onKeyDown handler when key is pressed on item', () => {
1866+
it('should call onKeyDown handler when key is pressed on item', async () => {
18671867
let onKeyDown = jest.fn();
1868-
let {getAllByRole} = renderListbox({}, {onKeyDown});
1869-
let options = getAllByRole('option');
1868+
renderListbox({}, {onKeyDown});
18701869

1871-
fireEvent.keyDown(options[0], {key: 'Delete'});
1870+
await user.tab();
1871+
await user.keyboard('{Delete}');
18721872
expect(onKeyDown).toHaveBeenCalledTimes(1);
18731873

1874-
fireEvent.keyDown(options[1], {key: 'Backspace'});
1874+
await user.keyboard('{Backspace}');
18751875
expect(onKeyDown).toHaveBeenCalledTimes(2);
18761876
});
18771877
});

0 commit comments

Comments
 (0)