2022-06-30 06:26:22 -10:00
|
|
|
import { i18n } from '@lingui/core'
|
|
|
|
import { I18nProvider } from '@lingui/react'
|
|
|
|
import { render } from '@testing-library/react'
|
2022-06-30 13:38:02 -10:00
|
|
|
import Web3Provider from 'components/Web3Provider'
|
2022-06-30 06:26:22 -10:00
|
|
|
import { DEFAULT_LOCALE } from 'constants/locales'
|
|
|
|
import { en } from 'make-plural/plurals'
|
|
|
|
import { ReactElement, ReactNode } from 'react'
|
2021-07-26 10:41:08 -07:00
|
|
|
import { Provider } from 'react-redux'
|
2021-09-21 18:21:28 -05:00
|
|
|
import store from 'state'
|
|
|
|
import ThemeProvider from 'theme'
|
2021-07-26 10:41:08 -07:00
|
|
|
|
2022-06-30 06:26:22 -10:00
|
|
|
import catalog from './locales/en-US'
|
|
|
|
|
|
|
|
i18n.load({
|
|
|
|
[DEFAULT_LOCALE]: catalog.messages,
|
|
|
|
})
|
|
|
|
i18n.loadLocaleData({
|
|
|
|
[DEFAULT_LOCALE]: { plurals: en },
|
|
|
|
})
|
|
|
|
i18n.activate(DEFAULT_LOCALE)
|
|
|
|
|
|
|
|
const MockedI18nProvider = ({ children }: any) => <I18nProvider i18n={i18n}>{children}</I18nProvider>
|
|
|
|
|
|
|
|
const WithProviders = ({ children }: { children?: ReactNode }) => {
|
2021-07-26 10:41:08 -07:00
|
|
|
return (
|
2022-06-30 06:26:22 -10:00
|
|
|
<MockedI18nProvider>
|
|
|
|
<Provider store={store}>
|
2022-06-30 13:38:02 -10:00
|
|
|
<Web3Provider>
|
2022-06-30 06:26:22 -10:00
|
|
|
<ThemeProvider>{children}</ThemeProvider>
|
2022-06-30 13:38:02 -10:00
|
|
|
</Web3Provider>
|
2022-06-30 06:26:22 -10:00
|
|
|
</Provider>
|
|
|
|
</MockedI18nProvider>
|
2021-07-26 10:41:08 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-06-30 06:26:22 -10:00
|
|
|
const customRender = (ui: ReactElement) => render(ui, { wrapper: WithProviders })
|
2021-07-26 10:41:08 -07:00
|
|
|
|
|
|
|
export * from '@testing-library/react'
|
|
|
|
export { customRender as render }
|