From 7c2ef3281fefa1263f266151a06ce97b28df7e59 Mon Sep 17 00:00:00 2001 From: Kyle Pinkham Date: Wed, 31 May 2017 23:32:48 -0700 Subject: [PATCH] Fixed ImageLoader Mock for Android Summary: When trying to mock an Image on Android, this error occurs referencing the ImageLoader mock in setup.js: ``` /Users/.../node_modules/react-native/jest/setup.js:120 return success(320,240); ^ TypeError: success is not a function at /Users/.../node_modules/react-native/jest/setup.js:120:8 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickCallback (internal/process/next_tick.js:104:9) ``` - Mocking Images works for iOS but not Android. - Since Image.android.js uses ImageLoader vs ImageViewManager, the code cannot be carried over from iOS. Since this is code within the testing framework, the existing tests should test this. If there is no existing test coverage, then this would need to be done. Closes https://github.com/facebook/react-native/pull/14262 Differential Revision: D5162640 Pulled By: shergin fbshipit-source-id: 5b1efbbb685b767e09b5c7fb05f073445c94a3aa --- jest/setup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest/setup.js b/jest/setup.js index 21336ab3e03..669be550aba 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -124,7 +124,7 @@ const mockNativeModules = { }, ImageLoader: { getSize: jest.fn( - (uri, success) => process.nextTick(() => success(320, 240)) + (url) => new Promise(() => ({width: 320, height: 240})) ), prefetchImage: jest.fn(), },