Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 4afbd50

Browse files
committed
Updated tests so console.error is logged.
1 parent 243e0e8 commit 4afbd50

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

tests/imageCacheHoc.test.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Define globals for eslint.
33
/* global describe it */
4-
/* global expect */
4+
/* global expect require */
55

66
// Load dependencies
77
import should from 'should'; // eslint-disable-line no-unused-vars
@@ -24,6 +24,21 @@ describe('CacheableImage', function() {
2424

2525
it('renders correctly', () => {
2626

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+
2742
const CacheableImage = imageCacheHoc(Image);
2843

2944
const styles = StyleSheet.create({
@@ -61,6 +76,21 @@ describe('CacheableImage', function() {
6176

6277
it('renders correctly with placeholder prop set', () => {
6378

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+
6494
const CacheableImage = imageCacheHoc(Image);
6595

6696
const styles = StyleSheet.create({
@@ -110,6 +140,21 @@ describe('CacheableImage', function() {
110140

111141
it('renders correctly with placeholder option set', () => {
112142

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+
113158
const styles = StyleSheet.create({
114159
container: {
115160
flex: 1,

0 commit comments

Comments
 (0)