Skip to content

Commit

Permalink
Updated tests so console.error is logged.
Browse files Browse the repository at this point in the history
  • Loading branch information
billmalarky committed Nov 21, 2017
1 parent 243e0e8 commit 4afbd50
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion tests/imageCacheHoc.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Define globals for eslint.
/* global describe it */
/* global expect */
/* global expect require */

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

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

//Mock values for local/remote file request logic.
const RNFetchBlob = require('react-native-fetch-blob');
RNFetchBlob.fs.exists
.mockReturnValueOnce(false) // mock not exist in local permanent dir
.mockReturnValueOnce(false) // mock not exist in local cache dir
.mockReturnValueOnce(false) // mock does not exist to get past clobber
.mockReturnValue(true);

RNFetchBlob.fetch
.mockReturnValue({
path: () => {
return '/this/is/path/to/file.jpg';
}
});

const CacheableImage = imageCacheHoc(Image);

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

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

//Mock values for local/remote file request logic.
const RNFetchBlob = require('react-native-fetch-blob');
RNFetchBlob.fs.exists
.mockReturnValueOnce(false) // mock not exist in local permanent dir
.mockReturnValueOnce(false) // mock not exist in local cache dir
.mockReturnValueOnce(false) // mock does not exist to get past clobber
.mockReturnValue(true);

RNFetchBlob.fetch
.mockReturnValue({
path: () => {
return '/this/is/path/to/file.jpg';
}
});

const CacheableImage = imageCacheHoc(Image);

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

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

//Mock values for local/remote file request logic.
const RNFetchBlob = require('react-native-fetch-blob');
RNFetchBlob.fs.exists
.mockReturnValueOnce(false) // mock not exist in local permanent dir
.mockReturnValueOnce(false) // mock not exist in local cache dir
.mockReturnValueOnce(false) // mock does not exist to get past clobber
.mockReturnValue(true);

RNFetchBlob.fetch
.mockReturnValue({
path: () => {
return '/this/is/path/to/file.jpg';
}
});

const styles = StyleSheet.create({
container: {
flex: 1,
Expand Down

0 comments on commit 4afbd50

Please sign in to comment.