import React from 'react';
import { ThemeProvider } from 'styled-components';
import { render } from '@testing-library/react';

import myTheme from './theme';

const getThemeProviderWrappingComponent = (theme: Record<string, unknown>) => (
  children: React.ReactNode,
) => <ThemeProvider theme={theme}>{children}</ThemeProvider>;

const renderwWithTheme = (
  tree: React.ReactNode,
  theme: Record<string, unknown> = myTheme,
) => {
  return render(getThemeProviderWrappingComponent(theme)(tree));
};

export default renderwWithTheme;
