Skip to content

Commit

Permalink
[IconButton] Add unit tests for color classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetta56 committed Nov 26, 2022
1 parent 0b9f72c commit 009a6a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/mui-material/src/IconButton/IconButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect } from 'chai';
import PropTypes from 'prop-types';
import { createRenderer, describeConformance } from 'test/utils';
import IconButton, { iconButtonClasses as classes } from '@mui/material/IconButton';
import { unstable_capitalize as capitalize } from '@mui/utils';
import Icon from '@mui/material/Icon';
import ButtonBase from '@mui/material/ButtonBase';

Expand Down Expand Up @@ -95,6 +96,16 @@ describe('<IconButton />', () => {
});
});

describe('prop: color', () => {
['primary', 'secondary', 'error', 'info', 'success', 'warning'].forEach((color) => {
it(`should render the ${color} class`, () => {
const { getByRole } = render(<IconButton color={color}>Hello World</IconButton>);
const button = getByRole('button');
expect(button).to.have.class(classes[`color${capitalize(color)}`]);
});
});
});

it('should raise a warning about onClick in children because of Firefox', () => {
expect(() => {
PropTypes.checkPropTypes(
Expand Down

0 comments on commit 009a6a6

Please sign in to comment.