Permalink
Browse files

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 #14262

Differential Revision: D5162640

Pulled By: shergin

fbshipit-source-id: 5b1efbbb685b767e09b5c7fb05f073445c94a3aa
  • Loading branch information...
kpink224 authored and facebook-github-bot committed Jun 1, 2017
1 parent 8394f9b commit 7c2ef3281fefa1263f266151a06ce97b28df7e59
Showing with 1 addition and 1 deletion.
  1. +1 −1 jest/setup.js
View
@@ -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(),
},

0 comments on commit 7c2ef32

Please sign in to comment.