Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Sep 26, 2022
1 parent fc4db41 commit e757db7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/mui-joy/src/Chip/Chip.test.js
@@ -1,6 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, describeConformance } from 'test/utils';
import { spy } from 'sinon';
import { createRenderer, describeConformance, fireEvent } from 'test/utils';
import { ThemeProvider } from '@mui/joy/styles';
import Chip, { chipClasses as classes } from '@mui/joy/Chip';
import { unstable_capitalize as capitalize } from '@mui/utils';
Expand Down Expand Up @@ -100,6 +101,15 @@ describe('<Chip />', () => {
expect(getByRole('button')).toBeVisible();
});

it('should call onClick', () => {
const handleClick = spy();
const { getByRole } = render(<Chip onClick={handleClick} />);

fireEvent.click(getByRole('button'));

expect(handleClick.callCount).to.equal(1);
});

it('renders action element when `componentsProps.action` is provided', () => {
const { getByRole } = render(<Chip componentsProps={{ action: {} }} />);

Expand Down

0 comments on commit e757db7

Please sign in to comment.