Skip to content

Commit d5c16c1

Browse files
[test] Add test to display options provided to the options prop even if loading is true. (#41675)
1 parent e85839f commit d5c16c1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/mui-material/src/Autocomplete/Autocomplete.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ describe('<Autocomplete />', () => {
145145
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
146146
expect(document.querySelector(`.${classes.paper}`).textContent).to.equal('Loading…');
147147
});
148+
149+
it('should show supplied options to the "options" prop even when loading', () => {
150+
render(
151+
<Autocomplete
152+
options={['one', 'two']}
153+
loading
154+
renderInput={(params) => <TextField {...params} autoFocus />}
155+
/>,
156+
);
157+
158+
fireEvent.keyDown(screen.getByRole('combobox'), { key: 'ArrowDown' });
159+
expect(document.querySelector(`.${classes.paper}`).textContent).not.to.equal('Loading…');
160+
161+
const listbox = screen.getByRole('listbox');
162+
const htmlOptions = listbox.querySelectorAll('li');
163+
expect(htmlOptions[0].innerHTML).to.equal('one');
164+
});
148165
});
149166

150167
describe('prop: autoHighlight', () => {

0 commit comments

Comments
 (0)