Skip to content

Commit 76773e0

Browse files
committed
[material-ui][Chip] Fix handling on event handlers
1 parent 5e948a6 commit 76773e0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,4 +733,28 @@ describe('<Chip />', () => {
733733
).not.to.throw();
734734
});
735735
});
736+
737+
it('should not throw on clicking Chip when onClick is not provided', () => {
738+
expect(() => {
739+
const { getByTestId } = render(<Chip data-testid="chip" />);
740+
const chip = getByTestId('chip');
741+
fireEvent.click(chip);
742+
}).not.throw();
743+
});
744+
745+
it('should not throw on keydown when onKeyDown is not provided', () => {
746+
expect(() => {
747+
const { getByTestId } = render(<Chip data-testid="chip" />);
748+
const chip = getByTestId('chip');
749+
fireEvent.keyDown(chip, { key: 'Enter' });
750+
}).not.throw();
751+
});
752+
753+
it('should not throw on keyup when onKeyUp is not provided', () => {
754+
expect(() => {
755+
const { getByTestId } = render(<Chip data-testid="chip" />);
756+
const chip = getByTestId('chip');
757+
fireEvent.keyUp(chip, { key: ' ' });
758+
}).not.throw();
759+
});
736760
});

0 commit comments

Comments
 (0)