Skip to content

Commit

Permalink
fix: improve tests to check highlighting index consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Feb 29, 2024
1 parent 3c3ee26 commit 76d899c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,10 @@ describe('Joy <Autocomplete />', () => {
// 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", () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-material/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,10 @@ describe('<Autocomplete />', () => {
// 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', () => {
Expand Down

0 comments on commit 76d899c

Please sign in to comment.