Mock random.js in tests using node crypto

This commit is contained in:
Tankred Hase 2020-05-01 08:35:36 +08:00
parent 52a8f530c6
commit dbf07544cf
No known key found for this signature in database
GPG Key ID: 8A9F1C42BFB264F6

View File

@ -1,3 +1,12 @@
import crypto from 'crypto';
import { promisify } from 'util';
jest.mock('../random', () => {
return {
randomBytes: jest.fn(size => promisify(crypto.randomBytes)(size)),
};
});
jest.mock('react-native-watch-connectivity', () => { jest.mock('react-native-watch-connectivity', () => {
return { return {
getIsWatchAppInstalled: jest.fn(), getIsWatchAppInstalled: jest.fn(),