summaryrefslogtreecommitdiff
path: root/test/mock-react-native-image.ts
blob: c01e3add55e66b95e643f971203fa39bea219758 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import * as ReactNative from 'react-native'
import mockFile from './mock-file'

jest.doMock('react-native', () => {
  // Extend ReactNative
  return Object.setPrototypeOf(
    {
      Image: {
        ...ReactNative.Image,
        resolveAssetSource: jest.fn((source) => mockFile), // eslint-disable-line @typescript-eslint/no-unused-vars
        getSize: jest.fn((
          uri: string, // eslint-disable-line @typescript-eslint/no-unused-vars
          success: (width: number, height: number) => void,
          failure?: (error: any) => void, // eslint-disable-line @typescript-eslint/no-unused-vars
        ) => success(100, 100)),
      },
    },
    ReactNative,
  )
})