From 76d899c5fdb1c744d3b3bae3d4bd5025a379cbac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 29 Feb 2024 18:16:05 +0100 Subject: [PATCH] fix: improve tests to check highlighting index consistency --- packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx | 4 ++++ packages/mui-material/src/Autocomplete/Autocomplete.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx index 4f473204247567..e08ed63fe1ee08 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx @@ -1409,6 +1409,10 @@ describe('Joy ', () => { // three option is added and autocomplete re-renders, restore the highlight setProps({ options: [{ label: 'one' }, { label: 'two' }, { label: 'three' }] }); checkHighlightIs(listbox, 'two'); + + fireEvent.keyDown(textbox, { key: 'ArrowDown' }); // goes to 'three' + + checkHighlightIs(listbox, 'three'); }); it("should reset the highlight when previously highlighted option doesn't exists in new options", () => { diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.test.js b/packages/mui-material/src/Autocomplete/Autocomplete.test.js index 4a7a90935dbd4e..57bf88e2dea692 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.test.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.test.js @@ -1839,6 +1839,10 @@ describe('', () => { // three option is added and autocomplete re-renders, restore the highlight setProps({ options: [{ label: 'one' }, { label: 'two' }, { label: 'three' }] }); checkHighlightIs(listbox, 'two'); + + fireEvent.keyDown(textbox, { key: 'ArrowDown' }); // goes to 'three' + + checkHighlightIs(listbox, 'three'); }); it('should reset the highlight when the input changed', () => {