testWrapper.tsx 537 B

123456789101112131415161718
  1. import React from 'react';
  2. import { ThemeProvider } from 'styled-components';
  3. import { render } from '@testing-library/react';
  4. import myTheme from './theme';
  5. const getThemeProviderWrappingComponent = (theme: Record<string, unknown>) => (
  6. children: React.ReactNode,
  7. ) => <ThemeProvider theme={theme}>{children}</ThemeProvider>;
  8. const renderwWithTheme = (
  9. tree: React.ReactNode,
  10. theme: Record<string, unknown> = myTheme,
  11. ) => {
  12. return render(getThemeProviderWrappingComponent(theme)(tree));
  13. };
  14. export default renderwWithTheme;