Skip to content

Commit

Permalink
Add test spying on onInputChange
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Jan 17, 2025
1 parent 672cb21 commit 4c51335
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/mui-material/src/useAutocomplete/useAutocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,24 @@ describe('useAutocomplete', () => {
fireEvent.click(button);
}).not.to.throw();
});

describe('prop: defaultValue', () => {
it('should not trigger onInputChange when defaultValue is provided', () => {
const onInputChange = spy();
const defaultValue = 'foo';

function Test() {
const { getInputProps } = useAutocomplete({
defaultValue,
onInputChange,
options: ['foo', 'bar'],
});

return <input {...getInputProps()} />;
}

render(<Test />);
expect(onInputChange.callCount).to.equal(0);
});
});
});

0 comments on commit 4c51335

Please sign in to comment.