ADD: Mock RNWatch test

This commit is contained in:
Marcos Rodriguez 2019-10-21 11:13:16 -04:00
parent 32592c272a
commit 0eb5e1952a
3 changed files with 15 additions and 5 deletions

View file

@ -1,4 +1,4 @@
import * as watch from 'react-native-watch-connectivity';
import * as Watch from 'react-native-watch-connectivity';
import { InteractionManager, Platform } from 'react-native';
const loc = require('./loc');
export default class WatchConnectivity {
@ -13,13 +13,13 @@ export default class WatchConnectivity {
getIsWatchAppInstalled() {
if (Platform.OS !== 'ios') return;
watch.getIsWatchAppInstalled((err, isAppInstalled) => {
Watch.getIsWatchAppInstalled((err, isAppInstalled) => {
if (!err) {
this.isAppInstalled = isAppInstalled;
this.sendWalletsToWatch();
}
});
watch.subscribeToMessages(async (err, message, reply) => {
Watch.subscribeToMessages(async (err, message, reply) => {
if (!err) {
if (message.request === 'createInvoice') {
const createInvoiceRequest = await this.handleLightningInvoiceCreateRequest(
@ -131,7 +131,7 @@ export default class WatchConnectivity {
});
}
watch.updateApplicationContext({ wallets });
Watch.updateApplicationContext({ wallets });
}
});
}

View file

@ -41,7 +41,10 @@
"preset": "react-native",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
}
},
"setupFiles": [
"./tests/setup.js"
]
},
"dependencies": {
"@babel/preset-env": "7.5.0",

7
tests/setup.js Normal file
View file

@ -0,0 +1,7 @@
jest.mock('react-native-watch-connectivity', () => {
return {
getIsWatchAppInstalled: jest.fn(),
subscribeToMessages: jest.fn(),
updateApplicationContext: jest.fn(),
}
})