about summary refs log tree commit diff
path: root/jest/test-utils.tsx
blob: 5a74a6ef6ffc948fc0e01e6ca3e1a429ca5c16ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react'
import {render} from '@testing-library/react-native'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
import {RootSiblingParent} from 'react-native-root-siblings'
import {SafeAreaProvider} from 'react-native-safe-area-context'
import {RootStoreProvider} from '../src/state'
import {ThemeProvider} from '../src/view/lib/ThemeContext'
import {mockedRootStore} from '../__mocks__/state-mock'

const customRender = (ui: any, rootStore?: any) =>
  render(
    // eslint-disable-next-line react-native/no-inline-styles
    <GestureHandlerRootView style={{flex: 1}}>
      <RootSiblingParent>
        <RootStoreProvider
          value={rootStore != null ? rootStore : mockedRootStore}>
          <ThemeProvider theme="light">
            <SafeAreaProvider>{ui}</SafeAreaProvider>
          </ThemeProvider>
        </RootStoreProvider>
      </RootSiblingParent>
    </GestureHandlerRootView>,
  )

// re-export everything
export * from '@testing-library/react-native'

// override render method
export {customRender as render}