import React, { PropsWithChildren } from 'react';
import { jest } from '@jest/globals';
import { BrowserRouter } from 'react-router-dom';
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
import { Provider } from 'react-redux';

import ErrorBoundary from '../src/components/ErrorBoundary';
import { store } from '../src/__data__/store';

export const AppContext = jest.fn(({ children }: PropsWithChildren) => (
  <Provider store={store}>
    <ChakraProvider theme={chakraTheme}>
      <ErrorBoundary>
        <BrowserRouter>{children}</BrowserRouter>
      </ErrorBoundary>
    </ChakraProvider>
  </Provider>
));
