1
1
2
2
// Define globals for eslint.
3
3
/* global describe it */
4
- /* global expect */
4
+ /* global expect require */
5
5
6
6
// Load dependencies
7
7
import should from 'should' ; // eslint-disable-line no-unused-vars
@@ -24,6 +24,21 @@ describe('CacheableImage', function() {
24
24
25
25
it ( 'renders correctly' , ( ) => {
26
26
27
+ //Mock values for local/remote file request logic.
28
+ const RNFetchBlob = require ( 'react-native-fetch-blob' ) ;
29
+ RNFetchBlob . fs . exists
30
+ . mockReturnValueOnce ( false ) // mock not exist in local permanent dir
31
+ . mockReturnValueOnce ( false ) // mock not exist in local cache dir
32
+ . mockReturnValueOnce ( false ) // mock does not exist to get past clobber
33
+ . mockReturnValue ( true ) ;
34
+
35
+ RNFetchBlob . fetch
36
+ . mockReturnValue ( {
37
+ path : ( ) => {
38
+ return '/this/is/path/to/file.jpg' ;
39
+ }
40
+ } ) ;
41
+
27
42
const CacheableImage = imageCacheHoc ( Image ) ;
28
43
29
44
const styles = StyleSheet . create ( {
@@ -61,6 +76,21 @@ describe('CacheableImage', function() {
61
76
62
77
it ( 'renders correctly with placeholder prop set' , ( ) => {
63
78
79
+ //Mock values for local/remote file request logic.
80
+ const RNFetchBlob = require ( 'react-native-fetch-blob' ) ;
81
+ RNFetchBlob . fs . exists
82
+ . mockReturnValueOnce ( false ) // mock not exist in local permanent dir
83
+ . mockReturnValueOnce ( false ) // mock not exist in local cache dir
84
+ . mockReturnValueOnce ( false ) // mock does not exist to get past clobber
85
+ . mockReturnValue ( true ) ;
86
+
87
+ RNFetchBlob . fetch
88
+ . mockReturnValue ( {
89
+ path : ( ) => {
90
+ return '/this/is/path/to/file.jpg' ;
91
+ }
92
+ } ) ;
93
+
64
94
const CacheableImage = imageCacheHoc ( Image ) ;
65
95
66
96
const styles = StyleSheet . create ( {
@@ -110,6 +140,21 @@ describe('CacheableImage', function() {
110
140
111
141
it ( 'renders correctly with placeholder option set' , ( ) => {
112
142
143
+ //Mock values for local/remote file request logic.
144
+ const RNFetchBlob = require ( 'react-native-fetch-blob' ) ;
145
+ RNFetchBlob . fs . exists
146
+ . mockReturnValueOnce ( false ) // mock not exist in local permanent dir
147
+ . mockReturnValueOnce ( false ) // mock not exist in local cache dir
148
+ . mockReturnValueOnce ( false ) // mock does not exist to get past clobber
149
+ . mockReturnValue ( true ) ;
150
+
151
+ RNFetchBlob . fetch
152
+ . mockReturnValue ( {
153
+ path : ( ) => {
154
+ return '/this/is/path/to/file.jpg' ;
155
+ }
156
+ } ) ;
157
+
113
158
const styles = StyleSheet . create ( {
114
159
container : {
115
160
flex : 1 ,
0 commit comments