summaryrefslogtreecommitdiff
path: root/test/mock-react-native-image.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/mock-react-native-image.ts')
-rw-r--r--test/mock-react-native-image.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/mock-react-native-image.ts b/test/mock-react-native-image.ts
new file mode 100644
index 0000000..eeae6bb
--- /dev/null
+++ b/test/mock-react-native-image.ts
@@ -0,0 +1,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,
+ )
+})