Skip to content

Commit

Permalink
chore: add UT
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzucchelli committed Oct 6, 2023
1 parent 598164d commit e90941e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ describe('Combobox', () => {
expect(getByRole('combobox')).toHaveValue('Strawberry 2');
});

it('should correctly change the rendered text value of the combobox when the value prop changes externally', async () => {
const onTextValueChange = jest.fn();
const { rerender } = renderRTL(<Component options={defaultOptions} onTextValueChange={onTextValueChange} />);

expect(onTextValueChange).toHaveBeenCalledTimes(1);
expect(onTextValueChange).toHaveBeenCalledWith('');

rerender(<Component options={defaultOptions} onTextValueChange={onTextValueChange} value="bagel" />);

expect(onTextValueChange).toHaveBeenCalledTimes(2);
expect(onTextValueChange).toHaveBeenCalledWith('bagel');
});

describe('callbacks', () => {
it('should fire onChange only when the value is changed not when the input does', async () => {
const onChange = jest.fn();
Expand Down

0 comments on commit e90941e

Please sign in to comment.