Skip to content

Commit d74e669

Browse files
committed
add mergeSlotProps tests
1 parent ce677e0 commit d74e669

File tree

6 files changed

+130
-12
lines changed

6 files changed

+130
-12
lines changed

packages/mui-material/src/Accordion/Accordion.spec.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { expectType } from '@mui/types';
3+
import { mergeSlotProps } from '@mui/material/utils';
34
import Accordion, { AccordionProps } from '@mui/material/Accordion';
45

56
function testOnChange() {
@@ -58,7 +59,7 @@ const AccordionComponentTest = () => {
5859
</Accordion>;
5960

6061
function Custom(props: AccordionProps) {
61-
const { slotProps, ...dialogProps } = props;
62+
const { slotProps, ...other } = props;
6263
return (
6364
<Accordion
6465
slotProps={{
@@ -76,7 +77,26 @@ function Custom(props: AccordionProps) {
7677
};
7778
},
7879
}}
79-
{...dialogProps}
80+
{...other}
81+
>
82+
test
83+
</Accordion>
84+
);
85+
}
86+
87+
function Custom2(props: AccordionProps) {
88+
const { slotProps, ...other } = props;
89+
return (
90+
<Accordion
91+
slotProps={{
92+
...slotProps,
93+
transition: mergeSlotProps(slotProps?.transition, {
94+
onExited: (node) => {
95+
expectType<HTMLElement, typeof node>(node);
96+
},
97+
}),
98+
}}
99+
{...other}
80100
>
81101
test
82102
</Accordion>

packages/mui-material/src/Dialog/Dialog.spec.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { expectType } from '@mui/types';
3+
import { mergeSlotProps } from '@mui/material/utils';
34
import Dialog, { DialogProps } from '@mui/material/Dialog';
45
import { PaperProps } from '@mui/material/Paper';
56

@@ -19,7 +20,7 @@ function Test() {
1920
}
2021

2122
function Custom(props: DialogProps) {
22-
const { slotProps, ...dialogProps } = props;
23+
const { slotProps, ...other } = props;
2324
return (
2425
<Dialog
2526
slotProps={{
@@ -37,7 +38,26 @@ function Custom(props: DialogProps) {
3738
};
3839
},
3940
}}
40-
{...dialogProps}
41+
{...other}
42+
>
43+
test
44+
</Dialog>
45+
);
46+
}
47+
48+
function Custom2(props: DialogProps) {
49+
const { slotProps, ...other } = props;
50+
return (
51+
<Dialog
52+
slotProps={{
53+
...slotProps,
54+
transition: mergeSlotProps(slotProps?.transition, {
55+
onExited: (node) => {
56+
expectType<HTMLElement, typeof node>(node);
57+
},
58+
}),
59+
}}
60+
{...other}
4161
>
4262
test
4363
</Dialog>

packages/mui-material/src/Popover/Popover.spec.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { expectType } from '@mui/types';
3+
import { mergeSlotProps } from '@mui/material/utils';
34
import { Popover, PaperProps, PopoverProps } from '@mui/material';
45

56
const paperProps: PaperProps<'span'> = {
@@ -27,7 +28,7 @@ function Test() {
2728
/>;
2829

2930
function Custom(props: PopoverProps) {
30-
const { slotProps, ...dialogProps } = props;
31+
const { slotProps, ...other } = props;
3132
return (
3233
<Popover
3334
slotProps={{
@@ -45,7 +46,26 @@ function Custom(props: PopoverProps) {
4546
};
4647
},
4748
}}
48-
{...dialogProps}
49+
{...other}
50+
>
51+
test
52+
</Popover>
53+
);
54+
}
55+
56+
function Custom2(props: PopoverProps) {
57+
const { slotProps, ...other } = props;
58+
return (
59+
<Popover
60+
slotProps={{
61+
...slotProps,
62+
transition: mergeSlotProps(slotProps?.transition, {
63+
onExited: (node) => {
64+
expectType<HTMLElement, typeof node>(node);
65+
},
66+
}),
67+
}}
68+
{...other}
4969
>
5070
test
5171
</Popover>

packages/mui-material/src/Snackbar/Snackbar.spec.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { mergeSlotProps } from '@mui/material/utils';
23
import Snackbar, { SnackbarProps } from '@mui/material/Snackbar';
34
import { expectType } from '@mui/types';
45

@@ -38,7 +39,7 @@ import { expectType } from '@mui/types';
3839
/>;
3940

4041
function Custom(props: SnackbarProps) {
41-
const { slotProps, ...dialogProps } = props;
42+
const { slotProps, ...other } = props;
4243
return (
4344
<Snackbar
4445
slotProps={{
@@ -56,7 +57,24 @@ function Custom(props: SnackbarProps) {
5657
};
5758
},
5859
}}
59-
{...dialogProps}
60+
{...other}
61+
/>
62+
);
63+
}
64+
65+
function Custom2(props: SnackbarProps) {
66+
const { slotProps, ...other } = props;
67+
return (
68+
<Snackbar
69+
slotProps={{
70+
...slotProps,
71+
transition: mergeSlotProps(slotProps?.transition, {
72+
onExited: (node) => {
73+
expectType<HTMLElement, typeof node>(node);
74+
},
75+
}),
76+
}}
77+
{...other}
6078
/>
6179
);
6280
}

packages/mui-material/src/StepContent/StepContent.spec.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as React from 'react';
2+
import { expectType } from '@mui/types';
3+
import { mergeSlotProps } from '@mui/material/utils';
24
import StepContent, { StepContentProps } from '@mui/material/StepContent';
35
import Fade from '@mui/material/Fade';
46
import Collapse from '@mui/material/Collapse';
@@ -13,7 +15,7 @@ import Zoom from '@mui/material/Zoom';
1315
<StepContent TransitionComponent={Zoom}>Step Content</StepContent>;
1416

1517
function Custom(props: StepContentProps) {
16-
const { slotProps, ...dialogProps } = props;
18+
const { slotProps, ...other } = props;
1719
return (
1820
<StepContent
1921
slotProps={{
@@ -31,7 +33,26 @@ function Custom(props: StepContentProps) {
3133
};
3234
},
3335
}}
34-
{...dialogProps}
36+
{...other}
37+
>
38+
test
39+
</StepContent>
40+
);
41+
}
42+
43+
function Custom2(props: StepContentProps) {
44+
const { slotProps, ...other } = props;
45+
return (
46+
<StepContent
47+
slotProps={{
48+
...slotProps,
49+
transition: mergeSlotProps(slotProps?.transition, {
50+
onExited: (node) => {
51+
expectType<HTMLElement, typeof node>(node);
52+
},
53+
}),
54+
}}
55+
{...other}
3556
>
3657
test
3758
</StepContent>

packages/mui-material/src/Tooltip/Tooltip.spec.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as React from 'react';
2+
import { expectType } from '@mui/types';
3+
import { mergeSlotProps } from '@mui/material/utils';
24
import Tooltip, { TooltipProps } from '@mui/material/Tooltip';
35

46
<Tooltip title="Hello">
@@ -53,7 +55,7 @@ const SlotComponentRef = React.forwardRef<HTMLDivElement>((props, ref) => {
5355
</Tooltip>;
5456

5557
function Custom(props: TooltipProps) {
56-
const { slotProps, ...dialogProps } = props;
58+
const { slotProps, ...other } = props;
5759
return (
5860
<Tooltip
5961
slotProps={{
@@ -71,7 +73,24 @@ function Custom(props: TooltipProps) {
7173
};
7274
},
7375
}}
74-
{...dialogProps}
76+
{...other}
77+
/>
78+
);
79+
}
80+
81+
function Custom2(props: TooltipProps) {
82+
const { slotProps, ...other } = props;
83+
return (
84+
<Tooltip
85+
slotProps={{
86+
...slotProps,
87+
transition: mergeSlotProps(slotProps?.transition, {
88+
onExited: (node) => {
89+
expectType<HTMLElement, typeof node>(node);
90+
},
91+
}),
92+
}}
93+
{...other}
7594
/>
7695
);
7796
}

0 commit comments

Comments
 (0)