-
-
Save acjr1910/70a080a2045a01d0b3cca3bb37e93ac5 to your computer and use it in GitHub Desktop.
react-native-blob-util mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// __mocks__/react-native-blob-util.js | |
module.exports = { | |
__esModule: true, | |
default: { | |
DocumentDir: jest.fn(), | |
config: jest.fn(() => ({ | |
fetch: jest.fn(() => ({ | |
progress: jest.fn().mockResolvedValue(true), | |
})), | |
})), | |
fs: { | |
cp: jest.fn().mockResolvedValue(true), | |
dirs: { | |
CacheDir: '/mockCacheDir', | |
}, | |
unlink: jest.fn(), | |
}, | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactNativeBlobUtil from 'react-native-blob-util'; | |
describe('SomeTest', () => { | |
beforeEach(() => { | |
jest.clearAllMocks(); | |
}); | |
it('handles errors', () => { | |
ReactNativeBlobUtil.config.mockReturnValueOnce({ | |
fetch: jest.fn().mockReturnValue({ | |
progress: jest.fn(() => | |
Object.assign(Promise.reject(), { cancel: jest.fn() }), | |
), | |
}), | |
}); | |
// assertions... | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment