Skip to content

Commit

Permalink
Add sizeMedium class and more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Mar 2, 2019
1 parent 0b0b4ad commit d447a4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/material-ui/src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const styles = theme => ({
minWidth: 24,
fontSize: 18,
},
/* Styles applied to the root element if `size="medium"`. */
sizeMedium: {},
});

/**
Expand All @@ -93,8 +95,8 @@ const IconButton = React.forwardRef(function IconButton(props, ref) {
{
[classes[`color${capitalize(color)}`]]: color !== 'default',
[classes.disabled]: disabled,
[classes.sizeSmall]: size === 'small',
},
classes[`size${capitalize(size)}`],
className,
)}
centerRipple
Expand Down
13 changes: 13 additions & 0 deletions packages/material-ui/src/IconButton/IconButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ describe('<IconButton />', () => {
it('should render with sizeSmall class when prop size="small" provided', () => {
const wrapper = shallow(<IconButton size="small">book</IconButton>);
assert.strictEqual(wrapper.hasClass(classes.sizeSmall), true);
assert.strictEqual(wrapper.hasClass(classes.sizeMedium), false);
});

it('should render with sizeMedium class when prop size="medium" provided', () => {
const wrapper = shallow(<IconButton size="medium">book</IconButton>);
assert.strictEqual(wrapper.hasClass(classes.sizeSmall), false);
assert.strictEqual(wrapper.hasClass(classes.sizeMedium), true);
});

it('should render with sizeMedium class when no size is provided', () => {
const wrapper = shallow(<IconButton size="medium">book</IconButton>);
assert.strictEqual(wrapper.hasClass(classes.sizeSmall), false);
assert.strictEqual(wrapper.hasClass(classes.sizeMedium), true);
});

describe('prop: disabled', () => {
Expand Down

0 comments on commit d447a4a

Please sign in to comment.