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 Mar 7, 2024
1 parent 9b620c4 commit de10310
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 @@ -1404,6 +1404,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 @@ -1838,6 +1838,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 de10310

Please sign in to comment.