Skip to content

Commit

Permalink
[Badge] Warn on default overlap value as well (#27573)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Aug 11, 2021
1 parent 25a1018 commit 5cc1d0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/material-ui/src/Badge/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Badge.propTypes = {
overlap: chainPropTypes(
PropTypes.oneOf(['circle', 'rectangle', 'circular', 'rectangular']),
(props) => {
const { overlap } = props;
const { overlap = 'rectangle' } = props;

if (overlap === 'rectangle') {
throw new Error(
Expand Down
16 changes: 14 additions & 2 deletions packages/material-ui/src/Badge/Badge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ describe('<Badge />', () => {
</div>
),
badgeContent: 10,
overlap: 'rectangular',
};

before(() => {
classes = getClasses(<Badge {...defaultProps} />);
});

describeConformance(
<Badge>
<Badge overlap="rectangular">
<div />
</Badge>,
() => ({
Expand All @@ -45,7 +46,11 @@ describe('<Badge />', () => {
it('renders children and badgeContent', () => {
const children = <div id="child" data-testid="child" />;
const badge = <div id="badge" data-testid="badge" />;
const { container, getByTestId } = render(<Badge badgeContent={badge}>{children}</Badge>);
const { container, getByTestId } = render(
<Badge badgeContent={badge} overlap="rectangular">
{children}
</Badge>,
);
expect(container.firstChild).to.contain(getByTestId('child'));
expect(container.firstChild).to.contain(getByTestId('badge'));
});
Expand Down Expand Up @@ -220,6 +225,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginTopRightRectangle: 'mui-class my-class' },
overlap: 'rectangular',
},
'props',
'Badge',
Expand All @@ -236,6 +242,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginBottomRightRectangle: 'mui-class my-class' },
overlap: 'rectangular',
},
'props',
'Badge',
Expand All @@ -252,6 +259,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginTopLeftRectangle: 'mui-class my-class' },
overlap: 'rectangular',
},
'props',
'Badge',
Expand All @@ -268,6 +276,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginBottomLeftRectangle: 'mui-class my-class' },
overlap: 'rectangular',
},
'props',
'Badge',
Expand All @@ -284,6 +293,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginTopRightCircle: 'mui-class my-class' },
overlap: 'circular',
},
'props',
'Badge',
Expand All @@ -300,6 +310,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginBottomRightCircle: 'mui-class my-class' },
overlap: 'circular',
},
'props',
'Badge',
Expand All @@ -316,6 +327,7 @@ describe('<Badge />', () => {
Badge.Naked.propTypes,
{
classes: { anchorOriginTopLeftCircle: 'mui-class my-class' },
overlap: 'circular',
},
'props',
'Badge',
Expand Down

0 comments on commit 5cc1d0f

Please sign in to comment.