generated from kubefirst/react-app-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2c6de0
commit 58f1e80
Showing
2 changed files
with
32 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Provider } from 'react-redux'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { ThemeProvider as ThemeProviderMUI } from '@mui/material/styles'; | ||
|
||
import { muiTheme } from '../theme/muiTheme'; | ||
import { theme } from '../theme'; | ||
import { makeStore } from '../redux/store'; | ||
import { ThemeProvider } from '../app/lib/styled-components'; | ||
|
||
function setupComponent<T>(Component: () => React.ReactNode, defaultProps?: T) { | ||
return async function (testProps?: Partial<T>) { | ||
const store = makeStore(); | ||
// Custom render function that includes ThemeProvider | ||
const customRender = (ui: React.ReactElement) => { | ||
return render( | ||
<ThemeProviderMUI theme={muiTheme}> | ||
<ThemeProvider theme={theme}>{ui}</ThemeProvider> | ||
</ThemeProviderMUI>, | ||
); | ||
}; | ||
|
||
return render( | ||
<ThemeProvider theme={theme}> | ||
<Provider store={store}> | ||
<Component {...defaultProps} {...testProps} /> | ||
</Provider> | ||
</ThemeProvider>, | ||
); | ||
}; | ||
} | ||
|
||
export default setupComponent; | ||
export default customRender; |