Skip to content

Commit

Permalink
[Modal] Remove deprecated BackdropComponent and BackdropProps fr…
Browse files Browse the repository at this point in the history
…om tests (#38018)
  • Loading branch information
sai6855 committed Jul 18, 2023
1 parent 5bedd50 commit db2968e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
42 changes: 37 additions & 5 deletions packages/mui-material/src/Modal/Modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('<Modal />', () => {
}

render(
<Modal open BackdropComponent={TestBackdrop}>
<Modal open slots={{ backdrop: TestBackdrop }}>
<div />
</Modal>,
);
Expand Down Expand Up @@ -165,7 +165,15 @@ describe('<Modal />', () => {
return <div data-testid="backdrop" data-timeout={transitionDuration} />;
}
render(
<Modal open BackdropComponent={TestBackdrop} BackdropProps={{ transitionDuration: 200 }}>
<Modal
open
slots={{ backdrop: TestBackdrop }}
slotProps={{
backdrop: {
transitionDuration: 200,
},
}}
>
<div />
</Modal>,
);
Expand All @@ -176,7 +184,15 @@ describe('<Modal />', () => {
it('should attach a handler to the backdrop that fires onClose', () => {
const onClose = spy();
const { getByTestId } = render(
<Modal onClose={onClose} open BackdropProps={{ 'data-testid': 'backdrop' }}>
<Modal
onClose={onClose}
open
slotProps={{
backdrop: {
'data-testid': 'backdrop',
},
}}
>
<div />
</Modal>,
);
Expand Down Expand Up @@ -220,7 +236,15 @@ describe('<Modal />', () => {
it('should call through to the user specified onBackdropClick callback', () => {
const onBackdropClick = spy();
const { getByTestId } = render(
<Modal onBackdropClick={onBackdropClick} open BackdropProps={{ 'data-testid': 'backdrop' }}>
<Modal
onClose={(event, reason) => {
if (reason === 'backdropClick') {
onBackdropClick();
}
}}
open
slotProps={{ backdrop: { 'data-testid': 'backdrop' } }}
>
<div />
</Modal>,
);
Expand All @@ -241,7 +265,15 @@ describe('<Modal />', () => {
}
const onBackdropClick = spy();
const { getByTestId } = render(
<Modal onBackdropClick={onBackdropClick} open BackdropComponent={CustomBackdrop}>
<Modal
onClose={(event, reason) => {
if (reason === 'backdropClick') {
onBackdropClick();
}
}}
open
slots={{ backdrop: CustomBackdrop }}
>
<div />
</Modal>,
);
Expand Down
12 changes: 11 additions & 1 deletion packages/mui-material/src/Popover/Popover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ describe('<Popover />', () => {
return <div data-testid="backdrop" data-invisible={invisible} />;
}
render(
<Popover open anchorEl={document.createElement('div')} BackdropComponent={TestBackdrop}>
<Popover
open
anchorEl={document.createElement('div')}
slotProps={{
root: {
slots: {
backdrop: TestBackdrop,
},
},
}}
>
<div />
</Popover>,
);
Expand Down

0 comments on commit db2968e

Please sign in to comment.