This repository was archived by the owner on Apr 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,40 @@ describe('CacheableImage', function() {
296
296
297
297
} ) ;
298
298
299
+ it ( '#_loadImage should warn developer on error getting local file path.' , ( ) => {
300
+
301
+ // Verify source uri prop only accepts web accessible urls.
302
+
303
+ const CacheableImage = imageCacheHoc ( Image ) ;
304
+
305
+ const imageUrl = 'https://img.wennermedia.com/5333a62d-07db-432a-92e2-198cafa38a14-326adb1a-d8ed-4a5d-b37e-5c88883e1989.png' ;
306
+
307
+ const cacheableImage = new CacheableImage ( { // eslint-disable-line no-unused-vars
308
+ source : {
309
+ uri : imageUrl
310
+ }
311
+ } ) ;
312
+
313
+ const testError = new Error ( 'Test error' ) ;
314
+
315
+ cacheableImage . fileSystem . getLocalFilePathFromUrl = ( ) => {
316
+ throw testError ;
317
+ } ;
318
+
319
+ // Cache console.warn
320
+ const consoleWarnCache = console . warn ; // eslint-disable-line no-console
321
+
322
+ console . warn = sinon . spy ( ) ; // eslint-disable-line no-console
323
+
324
+ cacheableImage . _loadImage ( imageUrl ) ;
325
+
326
+ console . warn . should . be . calledWithExactly ( testError ) ; // eslint-disable-line no-console
327
+
328
+ // Re-apply console.warn
329
+ console . warn = consoleWarnCache ; // eslint-disable-line no-console
330
+
331
+ } ) ;
332
+
299
333
it ( '#render with valid props does not throw an error.' , ( ) => {
300
334
301
335
const CacheableImage = imageCacheHoc ( Image ) ;
You can’t perform that action at this time.
0 commit comments