From 3098cce48a0fcce27c15de94d59ef84fbf26c75a Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Wed, 9 Nov 2022 13:44:37 -0800 Subject: [PATCH] [core] ESLint fixes for tests (#34924) Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com> --- .../MaterialUIComponents.js | 4 +- .../useAutocomplete.test.js | 16 +- .../src/BadgeUnstyled/BadgeUnstyled.spec.tsx | 5 +- .../ButtonUnstyled/ButtonUnstyled.spec.tsx | 5 +- .../src/ButtonUnstyled/useButton.test.tsx | 28 +- .../mui-base/src/FocusTrap/FocusTrap.test.js | 22 +- .../FormControlUnstyled.spec.tsx | 67 +- .../src/InputUnstyled/InputUnstyled.spec.tsx | 5 +- .../useControllableReducer.test.tsx | 16 +- .../src/ListboxUnstyled/useListbox.test.tsx | 24 +- .../MenuItemUnstyled.spec.tsx | 5 +- .../src/MenuUnstyled/MenuUnstyled.spec.tsx | 5 +- .../src/ModalUnstyled/ModalUnstyled.spec.tsx | 5 +- .../MultiSelectUnstyled.spec.tsx | 5 +- .../OptionGroupUnstyled.spec.tsx | 5 +- .../OptionUnstyled/OptionUnstyled.spec.tsx | 5 +- .../PopperUnstyled/PopperUnstyled.spec.tsx | 5 +- .../SelectUnstyled/SelectUnstyled.spec.tsx | 5 +- .../SelectUnstyled/SelectUnstyled.test.tsx | 20 +- .../SliderUnstyled/SliderUnstyled.spec.tsx | 5 +- .../SnackbarUnstyled.spec.tsx | 4 +- .../SwitchUnstyled/SwitchUnstyled.spec.tsx | 5 +- .../TabPanelUnstyled.spec.tsx | 5 +- .../src/TabUnstyled/TabUnstyled.spec.tsx | 5 +- .../TablePaginationActionsUnstyled.spec.tsx | 5 +- .../TablePaginationUnstyled.test.tsx | 4 +- .../TabsListUnstyled.spec.tsx | 5 +- .../src/TabsUnstyled/TabsUnstyled.spec.tsx | 5 +- .../src/utils/appendOwnerState.test.ts | 4 +- .../mui-base/src/utils/useSlotProps.test.tsx | 8 +- .../mui-joy/src/MenuItem/MenuItem.test.js | 8 +- packages/mui-joy/src/Modal/Modal.test.tsx | 22 +- packages/mui-joy/src/SvgIcon/SvgIcon.spec.tsx | 4 +- packages/mui-joy/src/SvgIcon/SvgIcon.test.js | 12 +- packages/mui-joy/src/Tab/Tab.test.tsx | 4 +- packages/mui-joy/src/TabList/TabList.test.tsx | 8 +- .../mui-joy/src/TabPanel/TabPanel.test.tsx | 4 +- packages/mui-joy/src/Tabs/Tabs.test.tsx | 4 +- .../src/styles/CssVarsProvider.test.tsx | 48 +- .../mui-joy/src/styles/ThemeProvider.test.tsx | 8 +- .../mui-lab/src/TreeView/TreeView.test.js | 4 +- .../src/Button/Button.spec.tsx | 6 +- .../TablePagination/TablePagination.test.js | 4 +- .../src/Accordion/Accordion.test.js | 13 +- packages/mui-material/src/Alert/Alert.test.js | 8 +- .../mui-material/src/AppBar/AppBar.spec.tsx | 27 +- .../src/Autocomplete/Autocomplete.spec.tsx | 6 +- .../src/Autocomplete/Autocomplete.test.js | 68 +- .../mui-material/src/Button/Button.spec.tsx | 10 +- .../src/CardHeader/CardHeader.spec.tsx | 5 +- .../src/Checkbox/Checkbox.test.js | 4 +- .../src/Collapse/Collapse.test.js | 16 +- .../DialogContentText.spec.tsx | 4 +- .../FormControlLabel/FormControlLabel.test.js | 4 +- packages/mui-material/src/Grid/Grid.test.js | 4 +- .../mui-material/src/Hidden/HiddenCss.test.js | 4 +- .../src/InputBase/InputBase.test.js | 4 +- .../src/ListItemText/ListItemText.spec.tsx | 4 +- packages/mui-material/src/Modal/Modal.test.js | 100 ++- .../mui-material/src/Paper/Paper.spec.tsx | 25 +- .../mui-material/src/Select/Select.test.js | 24 +- .../mui-material/src/Slider/Slider.test.js | 6 +- .../src/Snackbar/Snackbar.test.js | 4 +- .../src/SpeedDial/SpeedDial.test.js | 4 +- .../src/StepContent/StepContent.test.js | 4 +- .../src/StepLabel/StepLabel.test.js | 12 +- .../mui-material/src/Stepper/Stepper.test.tsx | 8 +- .../mui-material/src/SvgIcon/SvgIcon.test.js | 12 +- .../TablePagination/TablePagination.test.js | 4 +- packages/mui-material/src/Tabs/Tabs.spec.tsx | 8 +- .../mui-material/src/Tooltip/Tooltip.test.js | 28 +- .../src/Typography/typography.spec.tsx | 4 +- .../src/styles/CssVarsProvider.spec.tsx | 4 +- .../src/styles/CssVarsProvider.test.js | 36 +- .../mui-material/src/styles/styled.spec.tsx | 10 +- .../mui-material/src/styles/styled.test.js | 16 +- .../src/useMediaQuery/useMediaQuery.test.js | 40 +- .../src/usePagination/usePagination.test.js | 4 +- .../useScrollTrigger/useScrollTrigger.test.js | 8 +- .../src/utils/isMuiElement.test.js | 4 +- .../test/typescript/components.spec.tsx | 793 ++++++++++-------- .../src/StylesProvider/StylesProvider.test.js | 4 +- .../src/makeStyles/makeStyles.test.js | 54 +- .../mui-styles/src/styled/styled.spec.tsx | 13 +- .../useThemeVariants/useThemeVariants.test.js | 4 +- .../src/withStyles/withStyles.test.js | 20 +- .../src/withTheme/withTheme.test.js | 4 +- packages/mui-styles/test/styles.spec.tsx | 16 +- packages/mui-system/src/createStyled.test.js | 8 +- .../src/cssVars/createCssVarsProvider.test.js | 88 +- .../src/cssVars/useCurrentColorScheme.test.js | 96 +-- .../styleFunctionSx/styleFunctionSx.spec.tsx | 4 +- packages/mui-system/src/styled.test.js | 8 +- .../mui-utils/src/chainpropTypes.spec.tsx | 2 +- .../src/elementAcceptingRef.test.tsx | 4 +- .../src/elementTypeAcceptingRef.test.tsx | 4 +- .../mui-utils/src/getDisplayName.test.tsx | 4 +- .../mui-utils/src/requirePropFactory.test.js | 8 +- packages/mui-utils/src/useId.test.js | 12 +- test/utils/until.test.js | 21 +- 100 files changed, 1210 insertions(+), 946 deletions(-) diff --git a/docs/data/material/getting-started/supported-components/MaterialUIComponents.js b/docs/data/material/getting-started/supported-components/MaterialUIComponents.js index 17208cff2cbbdf..43e3ab9c5a988a 100644 --- a/docs/data/material/getting-started/supported-components/MaterialUIComponents.js +++ b/docs/data/material/getting-started/supported-components/MaterialUIComponents.js @@ -254,9 +254,7 @@ export default function MaterialUIComponents() { Support in MUI X ) : null} - {component.materialUI === 'Composable' ? ( - {'Composable'} - ) : null} + {component.materialUI === 'Composable' ? 'Composable' : null} {component.materialUI == null ? '❌ No support' : null} diff --git a/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.test.js b/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.test.js index f964fa6da09333..8b1726dc09c258 100644 --- a/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.test.js +++ b/packages/mui-base/src/AutocompleteUnstyled/useAutocomplete.test.js @@ -8,7 +8,7 @@ describe('useAutocomplete', () => { const { render } = createRenderer(); it('should preserve DOM nodes of options when re-ordering', () => { - const Test = (props) => { + function Test(props) { const { options } = props; const { groupedOptions, @@ -37,7 +37,7 @@ describe('useAutocomplete', () => { ) : null} ); - }; + } const { rerender } = render(); const [fooOptionAsFirst, barOptionAsSecond] = screen.getAllByRole('option'); @@ -235,7 +235,7 @@ describe('useAutocomplete', () => { this.skip(); } - const Test = (props) => { + function Test(props) { const { options } = props; const { groupedOptions, @@ -263,7 +263,7 @@ describe('useAutocomplete', () => { ) : null} ); - }; + } const node16ErrorMessage = "Error: Uncaught [TypeError: Cannot read properties of null (reading 'removeAttribute')]"; @@ -299,12 +299,12 @@ describe('useAutocomplete', () => { describe('prop: freeSolo', () => { it('should not reset if the component value does not change on blur', () => { - const Test = (props) => { + function Test(props) { const { options } = props; const { getInputProps } = useAutocomplete({ options, open: true, freeSolo: true }); return ; - }; + } render(); const input = screen.getByRole('combobox'); @@ -318,7 +318,7 @@ describe('useAutocomplete', () => { }); it('should allow tuples or arrays as value when multiple=false', () => { - const Test = () => { + function Test() { const defaultValue = ['bar']; const { getClearProps, getInputProps } = useAutocomplete({ @@ -341,7 +341,7 @@ describe('useAutocomplete', () => { ; + function MyCloseButton() { + return ; + } render( {}} components={{ CloseButton: MyCloseButton }}> diff --git a/packages/mui-material/src/AppBar/AppBar.spec.tsx b/packages/mui-material/src/AppBar/AppBar.spec.tsx index 9afb473eea8a94..8600ddcd018553 100644 --- a/packages/mui-material/src/AppBar/AppBar.spec.tsx +++ b/packages/mui-material/src/AppBar/AppBar.spec.tsx @@ -1,16 +1,21 @@ import * as React from 'react'; import AppBar from '@mui/material/AppBar'; -const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = () =>
; +const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = + function CustomComponent() { + return
; + }; -const AppBarTest = () => ( -
- - +function AppBarTest() { + return ( +
+ + - - - {/* @ts-expect-error missing stringProp and numberProp */} - -
-); + + + {/* @ts-expect-error missing stringProp and numberProp */} + +
+ ); +} diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx index 5fd0a39c0177ce..d2f6ab028c9040 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx +++ b/packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx @@ -71,9 +71,9 @@ interface Tag { label: string; } type TagComponentProps = Tag & React.HTMLAttributes; -const TagComponent = ({ color, label, ...other }: TagComponentProps) => ( -
{label}
-); +function TagComponent({ color, label, ...other }: TagComponentProps) { + return
{label}
; +} function renderTags(value: Tag[], getTagProps: AutocompleteRenderGetTagProps) { return value.map((tag: Tag, index) => { diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.test.js b/packages/mui-material/src/Autocomplete/Autocomplete.test.js index 2fd224e79b018c..4ab7e72c573b00 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.test.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.test.js @@ -648,21 +648,23 @@ describe('', () => { it('should trigger a form expectedly', () => { const handleSubmit = spy(); - const Test = (props) => ( -
{ - if (!event.defaultPrevented && event.key === 'Enter') { - handleSubmit(); - } - }} - > - } - {...props} - /> -
- ); + function Test(props) { + return ( +
{ + if (!event.defaultPrevented && event.key === 'Enter') { + handleSubmit(); + } + }} + > + } + {...props} + /> +
+ ); + } const { setProps } = render(); let textbox = screen.getByRole('combobox'); @@ -2430,26 +2432,28 @@ describe('', () => { it('should prevent the default event handlers', () => { const handleChange = spy(); const handleSubmit = spy(); - const Test = () => ( -
{ - if (!event.defaultPrevented && event.key === 'Enter') { - handleSubmit(); - } - }} - > - { - if (event.key === 'Enter') { - event.defaultMuiPrevented = true; + if (!event.defaultPrevented && event.key === 'Enter') { + handleSubmit(); } }} - renderInput={(params) => } - /> -
- ); + > + { + if (event.key === 'Enter') { + event.defaultMuiPrevented = true; + } + }} + renderInput={(params) => } + /> +
+ ); + } render(); const textbox = screen.getByRole('combobox'); fireEvent.keyDown(textbox, { key: 'ArrowDown' }); diff --git a/packages/mui-material/src/Button/Button.spec.tsx b/packages/mui-material/src/Button/Button.spec.tsx index e13daf6220fe9a..1250869cfb83d9 100644 --- a/packages/mui-material/src/Button/Button.spec.tsx +++ b/packages/mui-material/src/Button/Button.spec.tsx @@ -9,7 +9,9 @@ const TestOverride = React.forwardRef((props, re
)); -const FakeIcon = () =>
Icon
; +function FakeIcon() { + return
Icon
; +} const buttonTest = () => (
@@ -86,9 +88,9 @@ const buttonTest = () => ( ); const ReactRouterLinkTest = () => { - const ButtonLink = (props: ButtonProps) => ( - ); - }; + } const { getByText } = render(); expect(() => { diff --git a/packages/mui-material/src/ListItemText/ListItemText.spec.tsx b/packages/mui-material/src/ListItemText/ListItemText.spec.tsx index a48e1ef7da52db..eab98a93e51fe2 100644 --- a/packages/mui-material/src/ListItemText/ListItemText.spec.tsx +++ b/packages/mui-material/src/ListItemText/ListItemText.spec.tsx @@ -1,7 +1,9 @@ import * as React from 'react'; import { ListItemText } from '@mui/material'; -const CustomComponent: React.FC<{ prop1: string; prop2: number }> = () =>
; +const CustomComponent: React.FC<{ prop1: string; prop2: number }> = function CustomComponent() { + return
; +}; function typographyPropsTest() { // @ts-expect-error diff --git a/packages/mui-material/src/Modal/Modal.test.js b/packages/mui-material/src/Modal/Modal.test.js index b5e1f771b93fc4..70ea0e748f230b 100644 --- a/packages/mui-material/src/Modal/Modal.test.js +++ b/packages/mui-material/src/Modal/Modal.test.js @@ -571,16 +571,18 @@ describe('', () => { clock.withFakeTimers(); it('should open and close', () => { - const TestCase = (props) => ( - - -
Hello
-
- -
World
-
-
- ); + function TestCase(props) { + return ( + + +
Hello
+
+ +
World
+
+
+ ); + } TestCase.propTypes = { open: PropTypes.bool, }; @@ -599,18 +601,20 @@ describe('', () => { }); it('should open and close with Transitions', () => { - const TestCase = (props) => ( - - - -
Hello
-
-
- -
World
-
-
- ); + function TestCase(props) { + return ( + + + +
Hello
+
+
+ +
World
+
+
+ ); + } const handleEntered = spy(); const handleExited = spy(); @@ -663,18 +667,20 @@ describe('', () => { clock.withFakeTimers(); it('when true it should close after Transition has finished', () => { - const TestCase = (props) => ( - - -
Hello
-
-
- ); + function TestCase(props) { + return ( + + +
Hello
+
+
+ ); + } const handleEntered = spy(); const handleExiting = spy(); const handleExited = spy(); @@ -719,18 +725,20 @@ describe('', () => { }); it('when false it should close before Transition has finished', () => { - const TestCase = (props) => ( - - -
Hello
-
-
- ); + function TestCase(props) { + return ( + + +
Hello
+
+
+ ); + } const handleEntered = spy(); const handleExiting = spy(); const handleExited = spy(); diff --git a/packages/mui-material/src/Paper/Paper.spec.tsx b/packages/mui-material/src/Paper/Paper.spec.tsx index 85a4b0b390d5e3..d1ac34ce0d91aa 100644 --- a/packages/mui-material/src/Paper/Paper.spec.tsx +++ b/packages/mui-material/src/Paper/Paper.spec.tsx @@ -1,15 +1,20 @@ import * as React from 'react'; import Paper from '@mui/material/Paper'; -const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = () =>
; +const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = + function CustomComponent() { + return
; + }; -const PaperTest = () => ( -
- - +function PaperTest() { + return ( +
+ + - - {/* @ts-expect-error */} - -
-); + + {/* @ts-expect-error */} + +
+ ); +} diff --git a/packages/mui-material/src/Select/Select.test.js b/packages/mui-material/src/Select/Select.test.js index bb00594406304f..8d8e7026f0547f 100644 --- a/packages/mui-material/src/Select/Select.test.js +++ b/packages/mui-material/src/Select/Select.test.js @@ -1230,17 +1230,19 @@ describe(' - - France - Germany - China - - - - -); +function AppBarTest() { + return ( + + + + + + + Title + + + + + ); +} -const AvatarTest = () => ( -
- { - expectType(elem); - }} - onClick={(event) => { - expectType, typeof event>(event); - log(event); - }} - alt="Image Alt" - src="example.jpg" - /> - - component="button" - ref={(elem) => { - expectType(elem); - }} - onClick={(event) => { - expectType, typeof event>(event); - log(event); - }} - alt="Image Alt" - src="example.jpg" - /> - {}} - onClick={(event: React.MouseEvent) => log(event)} - alt="Image Alt" - src="example.jpg" - /> - - - component={TestOverride} - ref={(elem) => { - expectType(elem); - }} - x={3} - alt="Image Alt" - src="example.jpg" - /> - {/* @ts-expect-error onClick isn't allowed since we're overriding with a component that doesn't have that prop: */} - -
-); +function AvatarTest() { + return ( +
+ { + expectType(elem); + }} + onClick={(event) => { + expectType, typeof event>(event); + log(event); + }} + alt="Image Alt" + src="example.jpg" + /> + + component="button" + ref={(elem) => { + expectType(elem); + }} + onClick={(event) => { + expectType, typeof event>(event); + log(event); + }} + alt="Image Alt" + src="example.jpg" + /> + {}} + onClick={(event: React.MouseEvent) => log(event)} + alt="Image Alt" + src="example.jpg" + /> + + + component={TestOverride} + ref={(elem) => { + expectType(elem); + }} + x={3} + alt="Image Alt" + src="example.jpg" + /> + {/* @ts-expect-error onClick isn't allowed since we're overriding with a component that doesn't have that prop: */} + +
+ ); +} -const AvatarClassName = () => ; +function AvatarClassName() { + return ; +} -const BadgeTest = () => ( - - - -); +function BadgeTest() { + return ( + + + + ); +} -const BottomNavigationTest = () => { +function BottomNavigationTest() { const value = 123; return ( @@ -165,7 +175,7 @@ const BottomNavigationTest = () => { Nearby} icon={} /> ); -}; +} const iconButtonTest = () => (
@@ -191,9 +201,10 @@ const iconButtonAsLinkTest = () => { const ForwardedLink = React.forwardRef((props, ref) => ( )); - const ExtendedIconButton: React.FC> = (props) => ( - - ); + const ExtendedIconButton: React.FC> = + function ExtendedIconButton(props) { + return ; + }; return ( @@ -201,103 +212,109 @@ const iconButtonAsLinkTest = () => { ); }; -const CardTest = () => ( - - - Word of the Day - - be-nev-o-lent - - adjective - - well meaning and kindly. -
a benevolent smile -
-
- - - -
-); - -const CardMediaTest = () => ( - - R} - title="Shrimp and Chorizo Paella" - subheader="September 14, 2016" - /> - - Contemplative Reptile - - - - This impressive paella is a perfect party dish and a fun meal to cook together with your - guests. Add 1 cup of frozen peas along with the mussels, if you like. - - - - - - - - - - - - - - +function CardTest() { + return ( + - - Method: - - - Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10 - minutes. - - - Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high heat. - Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly browned, 6 - to 8 minutes. Transfer shrimp to a large plate and set aside, leaving chicken and chorizo - in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, salt and pepper, and cook, - stirring often until thickened and fragrant, about 10 minutes. Add saffron broth and - remaining 4 1/2 cups chicken broth; bring to a boil. + Word of the Day + + be-nev-o-lent - - Add rice and stir very gently to distribute. Top with artichokes and peppers, and cook - without stirring, until most of the liquid is absorbed, 15 to 18 minutes. Reduce heat to - medium-low, add reserved shrimp and mussels, tucking them down into the rice, and cook - again without stirring, until mussels have opened and rice is just tender, 5 to 7 minutes - more. (Discard any mussels that don't open.) - - - Set aside off of the heat to let rest for 10 minutes, and then serve. + adjective + + well meaning and kindly. +
a benevolent smile
-
-
-); + + + + + ); +} -const ChipsTest = () => ( -
- - M} label="Clickable Chip" onClick={(e) => log(e)} /> - } label="Deletable Chip" onDelete={(e) => log(e)} /> - +function CardMediaTest() { + return ( + + R} + title="Shrimp and Chorizo Paella" + subheader="September 14, 2016" + /> + + Contemplative Reptile + + + + This impressive paella is a perfect party dish and a fun meal to cook together with your + guests. Add 1 cup of frozen peas along with the mussels, if you like. + + + + - - } - label="Clickable Deletable Chip" - onClick={(e) => log(e)} - onDelete={(e) => log(e)} - /> -
-); +
+ + + + + + + + + + + Method: + + + Heat 1/2 cup of the broth in a pot until simmering, add saffron and set aside for 10 + minutes. + + + Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over medium-high + heat. Add chicken, shrimp and chorizo, and cook, stirring occasionally until lightly + browned, 6 to 8 minutes. Transfer shrimp to a large plate and set aside, leaving chicken + and chorizo in the pan. Add pimentón, bay leaves, garlic, tomatoes, onion, salt and + pepper, and cook, stirring often until thickened and fragrant, about 10 minutes. Add + saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil. + + + Add rice and stir very gently to distribute. Top with artichokes and peppers, and cook + without stirring, until most of the liquid is absorbed, 15 to 18 minutes. Reduce heat to + medium-low, add reserved shrimp and mussels, tucking them down into the rice, and cook + again without stirring, until mussels have opened and rice is just tender, 5 to 7 + minutes more. (Discard any mussels that don't open.) + + + Set aside off of the heat to let rest for 10 minutes, and then serve. + + + + + ); +} -const DialogTest = () => { +function ChipsTest() { + return ( +
+ + M} label="Clickable Chip" onClick={(e) => log(e)} /> + } label="Deletable Chip" onDelete={(e) => log(e)} /> + + + + } + label="Clickable Deletable Chip" + onClick={(e) => log(e)} + onDelete={(e) => log(e)} + /> +
+ ); +} + +function DialogTest() { const emails = ['username@gmail.com', 'user02@gmail.com']; return ( log(event)} open> @@ -376,16 +393,18 @@ const DialogTest = () => { ); -}; +} -const DividerTest = () => ( -
- - -
-); +function DividerTest() { + return ( +
+ + +
+ ); +} -const DrawerTest = () => { +function DrawerTest() { const open = { top: false, left: false, @@ -434,9 +453,9 @@ const DrawerTest = () => {
); -}; +} -const SwipeableDrawerTest = () => { +function SwipeableDrawerTest() { const open = { top: false, left: false, @@ -486,74 +505,82 @@ const SwipeableDrawerTest = () => {
); -}; +} -const AccordionTest = () => ( -
- log(e)} expanded disabled> - - - - - }> - ... - - - ... - - - - - -
-); +function AccordionTest() { + return ( +
+ log(e)} expanded disabled> + + + + + }> + ... + + + ... + + + + + +
+ ); +} -const GridTest = () => ( - - - ... - - - ... - - - ... - - - ... +function GridTest() { + return ( + + + ... + + + ... + + + ... + + + ... + - -); + ); +} -const ImageListTest = () => ( - log(e)}> - log(e)}> - alt text - - , - -); +function ImageListTest() { + return ( + log(e)}> + log(e)}> + alt text + + , + + ); +} -const ListTest = () => ( - - {[0, 1, 2, 3].map((value) => ( - log(e)}> - - - - - - - +function ListTest() { + return ( + + {[0, 1, 2, 3].map((value) => ( + log(e)}> + + + + + + + + + ))} + + an item - ))} - - an item - - -); + + ); +} -const MenuTest = () => { +function MenuTest() { const anchorEl = document.getElementById('foo')!; const options = [ 'Show all notification content', @@ -616,25 +643,29 @@ const MenuTest = () => { /> ); -}; +} -const CircularProgressTest = () => ( -
- - - - -
-); +function CircularProgressTest() { + return ( +
+ + + + +
+ ); +} -const LinearProgressTest = () => ( -
- - -
-); +function LinearProgressTest() { + return ( +
+ + +
+ ); +} -const SelectionControlTest = () => { +function SelectionControlTest() { const state = { checkedA: true, checkedB: false, @@ -682,9 +713,9 @@ const SelectionControlTest = () => { /> ); -}; +} -const SwitchTest = () => { +function SwitchTest() { const state = { checkedA: true, checkedB: false, @@ -718,39 +749,41 @@ const SwitchTest = () => { />
); -}; +} -const SnackbarTest = () => ( -
- - log(event)} - ContentProps={ - { - // 'aria-describedby': 'message-id', - // ^ will work once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/22582 is merged. +function SnackbarTest() { + return ( +
+ + log(event)} + ContentProps={ + { + // 'aria-describedby': 'message-id', + // ^ will work once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/22582 is merged. + } } - } - message={Note archived} - action={[ - , - log(e)}> - - , - ]} - /> -
-); + message={Note archived} + action={[ + , + log(e)}> + + , + ]} + /> +
+ ); +} -const SnackbarContentTest = () => { +function SnackbarContentTest() { const action = (
); -}; +} const StepperTest = () => class DotsMobileStepper extends React.Component<{ @@ -845,100 +878,118 @@ const TableTest = () => { ]; }; -const TextFieldTest = () => ( -
- - Name} value="Alice" /> - log({ name: event.currentTarget.value })} - /> - - - -
-); - -const SelectTest = () => ( - -); +function TextFieldTest() { + return ( +
+ + Name} value="Alice" /> + log({ name: event.currentTarget.value })} + /> + + + +
+ ); +} -const InputAdornmentTest = () => ( - alert('Hello')}> - Some Icon - -); +function SelectTest() { + return ( + + ); +} -const TooltipComponentTest = () => ( -
- - - - Add} placement="top-start"> - - -
-); +function InputAdornmentTest() { + return ( + alert('Hello')}> + Some Icon + + ); +} -const ClickAwayListenerComponentTest = () => ( - {}}> -
- -); +function TooltipComponentTest() { + return ( +
+ + + + Add} placement="top-start"> + + +
+ ); +} -const TransitionTest = () => ( - - -
- - -
- - {}}> +function ClickAwayListenerComponentTest() { + return ( + {}}>
- - -); + + ); +} -const BackdropTest = () => {}} />; +function TransitionTest() { + return ( + + +
+ + +
+ + {}}> +
+ + + ); +} -const PopoverTest = () => ; +function BackdropTest() { + return {}} />; +} -const InputLabelTest = () => ( - -); +function PopoverTest() { + return ; +} -const LinkTest = () => { +function InputLabelTest() { + return ( + + ); +} + +function LinkTest() { const dudUrl = 'javascript'; return ( @@ -951,7 +1002,7 @@ const LinkTest = () => { ); -}; +} const refTest = () => { // for a detailed explanation of refs in react see https://github.com/mui/material-ui/pull/15199 @@ -982,6 +1033,10 @@ const refTest = () => { />; }; -const CssBaselineTest = () => Test; +function CssBaselineTest() { + return Test; +} -const ScopedCssBaselineTest = () => Test; +function ScopedCssBaselineTest() { + return Test; +} diff --git a/packages/mui-styles/src/StylesProvider/StylesProvider.test.js b/packages/mui-styles/src/StylesProvider/StylesProvider.test.js index 66075395b8a8c4..ade0f6c3b18663 100644 --- a/packages/mui-styles/src/StylesProvider/StylesProvider.test.js +++ b/packages/mui-styles/src/StylesProvider/StylesProvider.test.js @@ -62,10 +62,10 @@ describe('StylesProvider', () => { }); const useStyles = makeStyles({ root: { display: 'flex' } }); - const Button = (props) => { + function Button(props) { const classes = useStyles(); return
); - }; + } render( @@ -160,10 +160,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Consumer = () => { + function Consumer() { const { setColorScheme } = useColorScheme(); return ; - }; + } render( @@ -194,10 +194,10 @@ describe('createCssVarsProvider', () => { defaultColorScheme: 'light', shouldSkipGeneratingVar: (keys) => keys[0] === 'typography' && keys[1] === 'h1', }); - const Consumer = () => { + function Consumer() { const theme = useTheme(); return
{theme.vars.typography.h1 || ''}
; - }; + } expect(() => render( @@ -225,7 +225,7 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Consumer = () => { + function Consumer() { const theme = useTheme(); return (
@@ -233,7 +233,7 @@ describe('createCssVarsProvider', () => {
{theme.vars.palette.grey || ''}
); - }; + } render( @@ -256,7 +256,7 @@ describe('createCssVarsProvider', () => { }, disableTransitionOnChange: true, }); - const Consumer = () => { + function Consumer() { const { mode, setMode } = useColorScheme(); return (
@@ -264,7 +264,7 @@ describe('createCssVarsProvider', () => { ;
); - }; + } render( @@ -297,7 +297,7 @@ describe('createCssVarsProvider', () => { }, disableTransitionOnChange: true, }); - const Consumer = () => { + function Consumer() { const { colorScheme, setColorScheme } = useColorScheme(); return (
@@ -305,7 +305,7 @@ describe('createCssVarsProvider', () => { ;
); - }; + } render( @@ -335,7 +335,7 @@ describe('createCssVarsProvider', () => { defaultColorScheme: 'light', disableTransitionOnChange: false, }); - const Consumer = () => { + function Consumer() { const { mode, setMode } = useColorScheme(); return (
@@ -343,7 +343,7 @@ describe('createCssVarsProvider', () => { ;
); - }; + } render( @@ -368,7 +368,7 @@ describe('createCssVarsProvider', () => { defaultColorScheme: 'light', disableTransitionOnChange: false, }); - const Consumer = () => { + function Consumer() { const { colorScheme, setColorScheme } = useColorScheme(); return (
@@ -376,7 +376,7 @@ describe('createCssVarsProvider', () => { ;
); - }; + } render( @@ -452,7 +452,7 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Consumer = () => { + function Consumer() { const { mode, setMode } = useColorScheme(); return (
@@ -460,7 +460,7 @@ describe('createCssVarsProvider', () => {
); - }; + } it('should save mode to localStorage', () => { render( @@ -545,10 +545,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Color = () => { + function Color() { const theme = useTheme(); return
{theme.vars.color}
; - }; + } it('use default color scheme if the storage value does not exist', () => { storage[DEFAULT_MODE_STORAGE_KEY] = 'unknown'; @@ -573,10 +573,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Text = ({ scale = 'md' }) => { + function Text({ scale = 'md' }) { const theme = useTheme(); return
{theme.vars.fontSize[scale]}
; - }; + } render( @@ -601,7 +601,7 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Swatch = () => { + function Swatch() { const theme = useTheme(); return (
@@ -609,7 +609,7 @@ describe('createCssVarsProvider', () => {
{theme.palette.color}
); - }; + } const comfortColor = '#007FFF'; render( { }, defaultColorScheme: 'light', }); - const Swatch = () => { + function Swatch() { const theme = useTheme(); return (
@@ -653,7 +653,7 @@ describe('createCssVarsProvider', () => {
{theme.vars.palette.bgcolor}
); - }; + } render( { }, defaultColorScheme: 'light', }); - const Consumer = () => { + function Consumer() { const theme = useTheme(); return
{Object.keys(theme.colorSchemes).join(', ')}
; - }; + } const { container } = render( @@ -700,10 +700,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Text = () => { + function Text() { const theme = useTheme(); return
{theme.vars.fontSize}
; - }; + } render( { }, defaultColorScheme: 'light', }); - const Text = () => { + function Text() { const theme = useTheme(); return
{theme.vars.components}
; - }; + } render( @@ -747,10 +747,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Text = () => { + function Text() { const { mode } = useColorScheme(); return
{mode}
; - }; + } const { container } = render( @@ -766,10 +766,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Text = () => { + function Text() { const { colorScheme } = useColorScheme(); return
{colorScheme}
; - }; + } const { container } = render( @@ -785,10 +785,10 @@ describe('createCssVarsProvider', () => { }, defaultColorScheme: 'light', }); - const Text = () => { + function Text() { const { colorScheme } = useColorScheme(); return
{colorScheme}
; - }; + } const { container } = render( { describe('Client', () => { it('has default mode=`light`', () => { - const Data = () => { + function Data() { const data = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return
{JSON.stringify(data)}
; - }; + } const { container } = render(); expect(JSON.parse(container.firstChild.textContent)).to.deep.equal({ @@ -115,7 +115,7 @@ describe('useCurrentColorScheme', () => { }); it('defaultMode=`dark`', () => { - const Data = () => { + function Data() { const data = useCurrentColorScheme({ defaultMode: 'dark', defaultLightColorScheme: 'light', @@ -123,7 +123,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'dark'], }); return
{JSON.stringify(data)}
; - }; + } const { container } = render(); expect(JSON.parse(container.firstChild.textContent)).to.deep.equal({ @@ -135,7 +135,7 @@ describe('useCurrentColorScheme', () => { }); it('defaultMode=`system`', () => { - const Data = () => { + function Data() { const data = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -143,7 +143,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'dark'], }); return
{JSON.stringify(data)}
; - }; + } const { container } = render(); expect(JSON.parse(container.firstChild.textContent)).to.deep.equal({ @@ -168,14 +168,14 @@ describe('useCurrentColorScheme', () => { }); it('change to `dark` mode', () => { - const Data = () => { + function Data() { const { setMode, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return ; - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -190,14 +190,14 @@ describe('useCurrentColorScheme', () => { it('change to `system` mode', () => { window.matchMedia = createMatchMedia(true); // system matches 'prefers-color-scheme: dark' - const Data = () => { + function Data() { const { setMode, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return ; - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -212,7 +212,7 @@ describe('useCurrentColorScheme', () => { }); it('reset mode', () => { - const Data = () => { + function Data() { const { setMode, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', @@ -225,7 +225,7 @@ describe('useCurrentColorScheme', () => {
); - }; + } render(); fireEvent.click(screen.getByTestId('dark')); @@ -241,14 +241,14 @@ describe('useCurrentColorScheme', () => { }); it('change colorScheme when mode is `light` should change `lightColorScheme`', () => { - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'paper', 'dark'], }); return ; - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -263,7 +263,7 @@ describe('useCurrentColorScheme', () => { it('change colorScheme when mode is `system` should look at systemMode', () => { window.matchMedia = createMatchMedia(true); // system matches 'prefers-color-scheme: dark' - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -271,7 +271,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'paper', 'dark', 'dim'], }); return ; - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -286,7 +286,7 @@ describe('useCurrentColorScheme', () => { }); it('change both light & dark color scheme at the same time', () => { - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -298,7 +298,7 @@ describe('useCurrentColorScheme', () => { {JSON.stringify(data)} ); - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -325,7 +325,7 @@ describe('useCurrentColorScheme', () => { }); it('change only the mode specified as key', () => { - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultMode: 'light', defaultLightColorScheme: 'light', @@ -339,7 +339,7 @@ describe('useCurrentColorScheme', () => {
); - }; + } const { getByText, getByTestId } = render(); fireEvent.click(getByText('first')); @@ -362,7 +362,7 @@ describe('useCurrentColorScheme', () => { }); it('able to setMode and setColorScheme in the same event', () => { - const Data = () => { + function Data() { const { setColorScheme, setMode, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', @@ -378,7 +378,7 @@ describe('useCurrentColorScheme', () => { {JSON.stringify(data)} ); - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -392,7 +392,7 @@ describe('useCurrentColorScheme', () => { }); it('reset colorScheme', () => { - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', @@ -405,7 +405,7 @@ describe('useCurrentColorScheme', () => {
); - }; + } render(); fireEvent.click(screen.getByTestId('dark')); @@ -421,7 +421,7 @@ describe('useCurrentColorScheme', () => { }); it('reset light & dark colorScheme', () => { - const Data = () => { + function Data() { const { setColorScheme, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', @@ -440,7 +440,7 @@ describe('useCurrentColorScheme', () => { />
); - }; + } render(); fireEvent.click(screen.getByTestId('dark')); @@ -458,7 +458,7 @@ describe('useCurrentColorScheme', () => { describe('Storage', () => { it('save dark mode', () => { - const Data = () => { + function Data() { const { setMode, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', @@ -473,7 +473,7 @@ describe('useCurrentColorScheme', () => { {JSON.stringify(data)} ); - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -484,7 +484,7 @@ describe('useCurrentColorScheme', () => { }); it('save system mode', () => { - const Data = () => { + function Data() { useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -492,7 +492,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'dark'], }); return null; - }; + } render(); expect(global.localStorage.setItem.calledWith(DEFAULT_MODE_STORAGE_KEY, 'system')).to.equal( true, @@ -500,7 +500,7 @@ describe('useCurrentColorScheme', () => { }); it('save lightColorScheme and darkColorScheme', () => { - const Data = () => { + function Data() { const { setMode, setColorScheme, ...data } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -517,7 +517,7 @@ describe('useCurrentColorScheme', () => { {JSON.stringify(data)} ); - }; + } const { container } = render(); fireEvent.click(container.firstChild); @@ -532,14 +532,14 @@ describe('useCurrentColorScheme', () => { it('use mode from localStorage if exists', () => { storage[DEFAULT_MODE_STORAGE_KEY] = 'dark'; - const Data = () => { + function Data() { const { setMode, setColorScheme, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return
{JSON.stringify(data)}
; - }; + } const { container } = render(); expect(JSON.parse(container.firstChild.textContent)).to.deep.equal({ @@ -553,14 +553,14 @@ describe('useCurrentColorScheme', () => { it('use mode & colorScheme from localStorage if exists', () => { storage[DEFAULT_MODE_STORAGE_KEY] = 'dark'; storage[`${DEFAULT_COLOR_SCHEME_STORAGE_KEY}-dark`] = 'dim'; - const Data = () => { + function Data() { const { setMode, setColorScheme, ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark', 'dim'], }); return
{JSON.stringify(data)}
; - }; + } const { container } = render(); expect(JSON.parse(container.firstChild.textContent)).to.deep.equal({ @@ -572,14 +572,14 @@ describe('useCurrentColorScheme', () => { }); it('storage mode changes from `light` to `dark`', () => { - const Data = () => { + function Data() { const { ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return ; - }; + } const { container } = render(); act(() => { @@ -596,14 +596,14 @@ describe('useCurrentColorScheme', () => { it('storage mode changes from `light` to `auto`', () => { window.matchMedia = createMatchMedia(true); // system matches 'prefers-color-scheme: dark' - const Data = () => { + function Data() { const { ...data } = useCurrentColorScheme({ defaultLightColorScheme: 'light', defaultDarkColorScheme: 'dark', supportedColorSchemes: ['light', 'dark'], }); return ; - }; + } const { container } = render(); act(() => { @@ -621,7 +621,7 @@ describe('useCurrentColorScheme', () => { it('storage mode is deleted', () => { storage[DEFAULT_MODE_STORAGE_KEY] = 'dark'; - const Data = () => { + function Data() { const { ...data } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -629,7 +629,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'dark'], }); return ; - }; + } const { container } = render(); act(() => { @@ -646,7 +646,7 @@ describe('useCurrentColorScheme', () => { }); it('storage lightColorScheme & darkColorScheme changes', () => { - const Data = () => { + function Data() { const { ...data } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -654,7 +654,7 @@ describe('useCurrentColorScheme', () => { supportedColorSchemes: ['light', 'dark', 'light-dim', 'dark-dim'], }); return ; - }; + } const { container } = render(); act(() => { @@ -693,7 +693,7 @@ describe('useCurrentColorScheme', () => { }); it('reset mode in storage', () => { - const Data = () => { + function Data() { const { setMode } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -706,7 +706,7 @@ describe('useCurrentColorScheme', () => {
); - }; + } render(); fireEvent.click(screen.getByTestId('dark')); @@ -719,7 +719,7 @@ describe('useCurrentColorScheme', () => { }); it('reset color scheme in storage', () => { - const Data = () => { + function Data() { const { setColorScheme } = useCurrentColorScheme({ defaultMode: 'system', defaultLightColorScheme: 'light', @@ -732,7 +732,7 @@ describe('useCurrentColorScheme', () => {
); - }; + } render(); fireEvent.click(screen.getByTestId('dark')); diff --git a/packages/mui-system/src/styleFunctionSx/styleFunctionSx.spec.tsx b/packages/mui-system/src/styleFunctionSx/styleFunctionSx.spec.tsx index 4884433c795bcf..5fe77a500ebb2f 100644 --- a/packages/mui-system/src/styleFunctionSx/styleFunctionSx.spec.tsx +++ b/packages/mui-system/src/styleFunctionSx/styleFunctionSx.spec.tsx @@ -5,7 +5,9 @@ interface Theme { color: string; } -const Text = (props: { sx?: SxProps }) => null; +function Text(props: { sx?: SxProps }) { + return null; +} // object ; diff --git a/packages/mui-system/src/styled.test.js b/packages/mui-system/src/styled.test.js index f88a5c540489b0..444aaa9bf1917c 100644 --- a/packages/mui-system/src/styled.test.js +++ b/packages/mui-system/src/styled.test.js @@ -568,8 +568,8 @@ describe('styled', () => { const { container } = render(Test); const classList = Array.from(container.firstChild.classList); - const regExp = new RegExp(`.*-MuiComponent-slot$`); - const regExpSC = new RegExp(`MuiComponent-slot.*`); + const regExp = /.*-MuiComponent-slot$/; + const regExpSC = /MuiComponent-slot.*/; let containsValidClass = false; classList.forEach((className) => { @@ -593,8 +593,8 @@ describe('styled', () => { const { container } = render(Test); const classList = Array.from(container.firstChild.classList); - const regExp = new RegExp(`.*-MuiComponent-root$`); - const regExpSC = new RegExp(`MuiComponent-root.*`); + const regExp = /.*-MuiComponent-root$/; + const regExpSC = /MuiComponent-root.*/; let containsValidClass = false; classList.forEach((className) => { diff --git a/packages/mui-utils/src/chainpropTypes.spec.tsx b/packages/mui-utils/src/chainpropTypes.spec.tsx index 7a7cb1c463227c..07c816d6d1d3bc 100644 --- a/packages/mui-utils/src/chainpropTypes.spec.tsx +++ b/packages/mui-utils/src/chainpropTypes.spec.tsx @@ -6,7 +6,7 @@ interface ChainProps { foo?: boolean; } -const Chain: React.FC = (props) => { +const Chain: React.FC = function Chain(props) { return
; }; diff --git a/packages/mui-utils/src/elementAcceptingRef.test.tsx b/packages/mui-utils/src/elementAcceptingRef.test.tsx index 8e33aa27668c7d..b8cd665a826eda 100644 --- a/packages/mui-utils/src/elementAcceptingRef.test.tsx +++ b/packages/mui-utils/src/elementAcceptingRef.test.tsx @@ -130,7 +130,9 @@ describe('elementAcceptingRef', () => { }); it('rejects function components', () => { - const Component = () => null; + function Component() { + return null; + } assertFail( , diff --git a/packages/mui-utils/src/elementTypeAcceptingRef.test.tsx b/packages/mui-utils/src/elementTypeAcceptingRef.test.tsx index 8e1c2d6367268f..a39ec1610fcbee 100644 --- a/packages/mui-utils/src/elementTypeAcceptingRef.test.tsx +++ b/packages/mui-utils/src/elementTypeAcceptingRef.test.tsx @@ -122,7 +122,9 @@ describe('elementTypeAcceptingRef', () => { } it('rejects function components', () => { - const Component = () => null; + function Component() { + return null; + } assertFail(Component, 'Did you accidentally provide a plain function component instead?'); }); diff --git a/packages/mui-utils/src/getDisplayName.test.tsx b/packages/mui-utils/src/getDisplayName.test.tsx index 9da9650a7b2e2b..4d30daac79c0fe 100644 --- a/packages/mui-utils/src/getDisplayName.test.tsx +++ b/packages/mui-utils/src/getDisplayName.test.tsx @@ -24,7 +24,9 @@ describe('utils/getDisplayName.js', () => { return
; } - const AndAnotherComponent = () =>
; + function AndAnotherComponent() { + return
; + } const AnonymousForwardRefComponent = React.forwardRef((props, ref) => (
diff --git a/packages/mui-utils/src/requirePropFactory.test.js b/packages/mui-utils/src/requirePropFactory.test.js index 743bf0ee7252c6..b36466f49047dc 100644 --- a/packages/mui-utils/src/requirePropFactory.test.js +++ b/packages/mui-utils/src/requirePropFactory.test.js @@ -114,7 +114,9 @@ describe('requirePropFactory', () => { }); it('should work with chained proptypes coming from the default props', () => { - const Test = () => null; + function Test() { + return null; + } Test.propTypes = { test: PropTypes.string, }; @@ -140,7 +142,9 @@ describe('requirePropFactory', () => { }); it('should validate default prop types coming from the component', () => { - const Test = () => null; + function Test() { + return null; + } Test.propTypes = { test: PropTypes.string, }; diff --git a/packages/mui-utils/src/useId.test.js b/packages/mui-utils/src/useId.test.js index a69bd9b5228f75..ec238bdfaf932b 100644 --- a/packages/mui-utils/src/useId.test.js +++ b/packages/mui-utils/src/useId.test.js @@ -7,10 +7,10 @@ describe('useId', () => { const { render, renderToString } = createRenderer(); it('returns the provided ID', () => { - const TestComponent = ({ id: idProp }) => { + function TestComponent({ id: idProp }) { const id = useId(idProp); return ; - }; + } const { hydrate } = renderToString(); const { setProps } = hydrate(); @@ -22,10 +22,10 @@ describe('useId', () => { }); it("generates an ID if one isn't provided", () => { - const TestComponent = ({ id: idProp }) => { + function TestComponent({ id: idProp }) { const id = useId(idProp); return ; - }; + } const { hydrate } = renderToString(); const { setProps } = hydrate(); @@ -86,10 +86,10 @@ describe('useId', () => { if (React.useId === undefined) { this.skip(); } - const TestComponent = () => { + function TestComponent() { const id = useId(); return ; - }; + } renderToString(); expect(screen.getByTestId('target').id).not.to.equal(''); diff --git a/test/utils/until.test.js b/test/utils/until.test.js index a13e4426372a3a..ee9edc05292249 100644 --- a/test/utils/until.test.js +++ b/test/utils/until.test.js @@ -4,8 +4,13 @@ import PropTypes from 'prop-types'; import { shallow } from 'enzyme'; import until from './until'; -const Div = () =>
; -const hoc = (Component) => () => ; +function Div() { + return
; +} +const hoc = (Component) => + function Wrapper() { + return ; + }; describe('until', () => { it('shallow renders the current wrapper one level deep', () => { @@ -64,11 +69,13 @@ describe('until', () => { }); it('shallow renders non-root wrappers', () => { - const Container = () => ( -
-
-
- ); + function Container() { + return ( +
+
+
+ ); + } const wrapper = until.call(shallow().find(Div)); expect(wrapper.contains(
)).to.equal(true); });