forked from nachaphon-phontree/UpdatesAPIDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
42 lines (37 loc) · 1.21 KB
/
setup.ts
File metadata and controls
42 lines (37 loc) · 1.21 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
// we always make sure 'react-native' gets included first
import * as ReactNative from "react-native"
import mockFile from "./mockFile"
// libraries to mock
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,
)
})
jest.mock("@react-native-async-storage/async-storage", () =>
require("@react-native-async-storage/async-storage/jest/async-storage-mock"),
)
jest.mock("i18n-js", () => ({
currentLocale: () => "en",
t: (key: string, params: Record<string, string>) => {
return `${key} ${JSON.stringify(params)}`
},
}))
declare const tron // eslint-disable-line @typescript-eslint/no-unused-vars
jest.useFakeTimers()
declare global {
let __TEST__: boolean
}