From 201ce0b0cbd7f9f83495249f49fd6832bc73d370 Mon Sep 17 00:00:00 2001 From: JC Date: Mon, 3 Mar 2025 17:38:41 -0700 Subject: [PATCH] fix: DRYing jest tests --- __mocks__/react-native.js | 16 ++++++++++++++++ __tests__/AddressBook.AbDetail.snapshot.tsx | 16 ---------------- __tests__/AddressBook.snapshot.tsx | 16 ---------------- __tests__/App.snapshot.tsx | 16 ---------------- __tests__/DetailLine.snapshot.tsx | 4 ++-- __tests__/Header.snapshot.tsx | 1 - __tests__/History.ValueTransferDetail.unit.tsx | 16 ---------------- __tests__/History.snapshot.tsx | 16 ---------------- __tests__/ImportUfvk.snapshot.tsx | 16 ---------------- __tests__/Info.es.unit.tsx | 15 --------------- __tests__/Info.snapshot.tsx | 16 ---------------- __tests__/Info.us.unit.tsx | 16 ---------------- __tests__/Insight.snapshot.tsx | 16 ---------------- __tests__/LoadedApp.snapshot.tsx | 16 ---------------- __tests__/LoadingApp.snapshot.tsx | 16 ---------------- __tests__/Memo.snapshot.tsx | 16 ---------------- __tests__/Messages.snapshot.tsx | 16 ---------------- __tests__/MessagesAddress.snapshot.tsx | 16 ---------------- __tests__/Pools.snapshot.tsx | 16 ---------------- __tests__/PrivKey.snapshot.tsx | 16 ---------------- __tests__/Receive.snapshot.tsx | 16 ---------------- __tests__/Rescan.snapshot.tsx | 16 ---------------- __tests__/Seed.snapshot.tsx | 16 ---------------- __tests__/Send.snapshot.tsx | 16 ---------------- __tests__/Settings.snapshot.tsx | 16 ---------------- __tests__/ShowUfvk.snapshot.tsx | 16 ---------------- __tests__/SyncReport.snapshot.tsx | 16 ---------------- .../__snapshots__/DetailLine.snapshot.tsx.snap | 13 ++++++++++++- 28 files changed, 30 insertions(+), 387 deletions(-) create mode 100644 __mocks__/react-native.js diff --git a/__mocks__/react-native.js b/__mocks__/react-native.js new file mode 100644 index 000000000..a20c338b7 --- /dev/null +++ b/__mocks__/react-native.js @@ -0,0 +1,16 @@ +jest.mock('react-native', () => { + const RN = jest.requireActual('react-native'); + + RN.NativeModules.RPCModule = { + execute: jest.fn(() => '{}'), + getLatestBlock: jest.fn(() => '{}'), + walletExists: jest.fn(() => 'false'), + getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), + setCryptoDefaultProvider: jest.fn(() => 'true'), + createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), + doSave: jest.fn(), + }; + RN.View = jest.fn(); + + return RN; +}); diff --git a/__tests__/AddressBook.AbDetail.snapshot.tsx b/__tests__/AddressBook.AbDetail.snapshot.tsx index abe679157..9df5afc0d 100644 --- a/__tests__/AddressBook.AbDetail.snapshot.tsx +++ b/__tests__/AddressBook.AbDetail.snapshot.tsx @@ -12,22 +12,6 @@ import { AddressBookActionEnum, AddressBookFileClass } from '../app/AppState'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockAddressBook } from '../__mocks__/dataMocks/mockAddressBook'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Address Book Details - test', () => { //snapshot test diff --git a/__tests__/AddressBook.snapshot.tsx b/__tests__/AddressBook.snapshot.tsx index 1677dca4d..eecc6f32e 100644 --- a/__tests__/AddressBook.snapshot.tsx +++ b/__tests__/AddressBook.snapshot.tsx @@ -11,22 +11,6 @@ import { AddressBook } from '../components/AddressBook'; import { mockAddressBook } from '../__mocks__/dataMocks/mockAddressBook'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Address Book - test', () => { //snapshot test diff --git a/__tests__/App.snapshot.tsx b/__tests__/App.snapshot.tsx index 2ec77ad16..87f30a132 100644 --- a/__tests__/App.snapshot.tsx +++ b/__tests__/App.snapshot.tsx @@ -8,22 +8,6 @@ import React from 'react'; import { render } from '@testing-library/react-native'; import App from '../App'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component App - test', () => { //snapshot test diff --git a/__tests__/DetailLine.snapshot.tsx b/__tests__/DetailLine.snapshot.tsx index 200a1610c..780b05f81 100644 --- a/__tests__/DetailLine.snapshot.tsx +++ b/__tests__/DetailLine.snapshot.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { render } from '@testing-library/react-native'; import DetailLine from '../components/Components/DetailLine'; -import { View } from 'react-native'; +import RegText from '../components/Components/RegText'; // test suite describe('Component DetailLine - test', () => { @@ -17,7 +17,7 @@ describe('Component DetailLine - test', () => { expect(detail.toJSON()).toMatchSnapshot(); }); test('DetailLine children - snapshot', () => { - const children = ; + const children = {'Hello'}; const detail = render(); expect(detail.toJSON()).toMatchSnapshot(); }); diff --git a/__tests__/Header.snapshot.tsx b/__tests__/Header.snapshot.tsx index 8c13a6406..4595b7d2b 100644 --- a/__tests__/Header.snapshot.tsx +++ b/__tests__/Header.snapshot.tsx @@ -12,7 +12,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; - // test suite describe('Component Header - test', () => { //snapshot test diff --git a/__tests__/History.ValueTransferDetail.unit.tsx b/__tests__/History.ValueTransferDetail.unit.tsx index f5bb68153..d1ecb8731 100644 --- a/__tests__/History.ValueTransferDetail.unit.tsx +++ b/__tests__/History.ValueTransferDetail.unit.tsx @@ -13,22 +13,6 @@ import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockValueTransfers } from '../__mocks__/dataMocks/mockValueTransfers'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component History ValueTransferDetail - test', () => { //unit test diff --git a/__tests__/History.snapshot.tsx b/__tests__/History.snapshot.tsx index db2a1b939..aba203c6b 100644 --- a/__tests__/History.snapshot.tsx +++ b/__tests__/History.snapshot.tsx @@ -15,22 +15,6 @@ import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockAddresses } from '../__mocks__/dataMocks/mockAddresses'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component History - test', () => { //snapshot test diff --git a/__tests__/ImportUfvk.snapshot.tsx b/__tests__/ImportUfvk.snapshot.tsx index 6615a4fad..7578f3df4 100644 --- a/__tests__/ImportUfvk.snapshot.tsx +++ b/__tests__/ImportUfvk.snapshot.tsx @@ -12,22 +12,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component ImportUfvk - test', () => { //snapshot test diff --git a/__tests__/Info.es.unit.tsx b/__tests__/Info.es.unit.tsx index 8a5187884..7fa8df279 100644 --- a/__tests__/Info.es.unit.tsx +++ b/__tests__/Info.es.unit.tsx @@ -21,21 +21,6 @@ jest.mock('react-native-localize', () => ({ }; }, })); -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); // test suite describe('Component Info - test', () => { diff --git a/__tests__/Info.snapshot.tsx b/__tests__/Info.snapshot.tsx index 25b176d02..bf9bdd06d 100644 --- a/__tests__/Info.snapshot.tsx +++ b/__tests__/Info.snapshot.tsx @@ -13,22 +13,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockZecPrice } from '../__mocks__/dataMocks/mockZecPrice'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Info - test', () => { //snapshot test diff --git a/__tests__/Info.us.unit.tsx b/__tests__/Info.us.unit.tsx index ceeced7fd..c320389f3 100644 --- a/__tests__/Info.us.unit.tsx +++ b/__tests__/Info.us.unit.tsx @@ -12,22 +12,6 @@ import { CurrencyEnum } from '../app/AppState'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockZecPrice } from '../__mocks__/dataMocks/mockZecPrice'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Info - test', () => { //unit test diff --git a/__tests__/Insight.snapshot.tsx b/__tests__/Insight.snapshot.tsx index 36e89da4c..b596f7043 100644 --- a/__tests__/Insight.snapshot.tsx +++ b/__tests__/Insight.snapshot.tsx @@ -12,22 +12,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Insight - test', () => { //snapshot test diff --git a/__tests__/LoadedApp.snapshot.tsx b/__tests__/LoadedApp.snapshot.tsx index be1a9e6d4..632eb13e3 100644 --- a/__tests__/LoadedApp.snapshot.tsx +++ b/__tests__/LoadedApp.snapshot.tsx @@ -21,22 +21,6 @@ import { mockBackground } from '../__mocks__/dataMocks/mockBackground'; import { mockSecurity } from '../__mocks__/dataMocks/mockSecurity'; import { mockAddressBook } from '../__mocks__/dataMocks/mockAddressBook'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component LoadedApp - test', () => { //snapshot test diff --git a/__tests__/LoadingApp.snapshot.tsx b/__tests__/LoadingApp.snapshot.tsx index a593609c8..133df3eda 100644 --- a/__tests__/LoadingApp.snapshot.tsx +++ b/__tests__/LoadingApp.snapshot.tsx @@ -20,22 +20,6 @@ import { mockServer } from '../__mocks__/dataMocks/mockServer'; import { mockBackground } from '../__mocks__/dataMocks/mockBackground'; import { mockSecurity } from '../__mocks__/dataMocks/mockSecurity'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component LoadingApp - test', () => { //snapshot test diff --git a/__tests__/Memo.snapshot.tsx b/__tests__/Memo.snapshot.tsx index 8c1972c2f..e4b2dfd91 100644 --- a/__tests__/Memo.snapshot.tsx +++ b/__tests__/Memo.snapshot.tsx @@ -10,22 +10,6 @@ import Memo from '../components/Memo'; import { defaultAppContextLoaded, ContextAppLoadedProvider } from '../app/context'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Memo - test', () => { //snapshot test diff --git a/__tests__/Messages.snapshot.tsx b/__tests__/Messages.snapshot.tsx index 27fc14fe8..9e08c23fd 100644 --- a/__tests__/Messages.snapshot.tsx +++ b/__tests__/Messages.snapshot.tsx @@ -15,22 +15,6 @@ import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockAddresses } from '../__mocks__/dataMocks/mockAddresses'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Messages - test', () => { //snapshot test diff --git a/__tests__/MessagesAddress.snapshot.tsx b/__tests__/MessagesAddress.snapshot.tsx index b0a8a7073..11469ab80 100644 --- a/__tests__/MessagesAddress.snapshot.tsx +++ b/__tests__/MessagesAddress.snapshot.tsx @@ -15,22 +15,6 @@ import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockAddresses } from '../__mocks__/dataMocks/mockAddresses'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Messages Address - test', () => { //snapshot test diff --git a/__tests__/Pools.snapshot.tsx b/__tests__/Pools.snapshot.tsx index e63d974f5..d7458fc79 100644 --- a/__tests__/Pools.snapshot.tsx +++ b/__tests__/Pools.snapshot.tsx @@ -12,22 +12,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Pools - test', () => { //snapshot test diff --git a/__tests__/PrivKey.snapshot.tsx b/__tests__/PrivKey.snapshot.tsx index c2bbe185c..7e62fc297 100644 --- a/__tests__/PrivKey.snapshot.tsx +++ b/__tests__/PrivKey.snapshot.tsx @@ -12,22 +12,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component PrivKey - test', () => { //snapshot test diff --git a/__tests__/Receive.snapshot.tsx b/__tests__/Receive.snapshot.tsx index 4e589a1bb..0bd248b2d 100644 --- a/__tests__/Receive.snapshot.tsx +++ b/__tests__/Receive.snapshot.tsx @@ -13,22 +13,6 @@ import { mockTranslate } from '../__mocks__/dataMocks/mockTranslate'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Receive - test', () => { //snapshot test diff --git a/__tests__/Rescan.snapshot.tsx b/__tests__/Rescan.snapshot.tsx index 49ab203bf..3f6593220 100644 --- a/__tests__/Rescan.snapshot.tsx +++ b/__tests__/Rescan.snapshot.tsx @@ -13,22 +13,6 @@ import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockWallet } from '../__mocks__/dataMocks/mockWallet'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Rescan - test', () => { //snapshot test diff --git a/__tests__/Seed.snapshot.tsx b/__tests__/Seed.snapshot.tsx index 73c0fdc8a..4f96f126d 100644 --- a/__tests__/Seed.snapshot.tsx +++ b/__tests__/Seed.snapshot.tsx @@ -19,22 +19,6 @@ import { mockWallet } from '../__mocks__/dataMocks/mockWallet'; import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Seed - test', () => { //snapshot test diff --git a/__tests__/Send.snapshot.tsx b/__tests__/Send.snapshot.tsx index b52de3b46..14ebe4c96 100644 --- a/__tests__/Send.snapshot.tsx +++ b/__tests__/Send.snapshot.tsx @@ -17,22 +17,6 @@ import { mockZecPrice } from '../__mocks__/dataMocks/mockZecPrice'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import mockSendPageState from '../__mocks__/dataMocks/mockSendPageState'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Send - test', () => { //snapshot test diff --git a/__tests__/Settings.snapshot.tsx b/__tests__/Settings.snapshot.tsx index fb283ca21..1bd284dfc 100644 --- a/__tests__/Settings.snapshot.tsx +++ b/__tests__/Settings.snapshot.tsx @@ -15,22 +15,6 @@ import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockServer } from '../__mocks__/dataMocks/mockServer'; import { mockWalletSettings } from '../__mocks__/dataMocks/mockWalletSettings'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component Settings - test', () => { //snapshot test diff --git a/__tests__/ShowUfvk.snapshot.tsx b/__tests__/ShowUfvk.snapshot.tsx index 66d90cbff..a6f2e67a0 100644 --- a/__tests__/ShowUfvk.snapshot.tsx +++ b/__tests__/ShowUfvk.snapshot.tsx @@ -14,22 +14,6 @@ import { mockInfo } from '../__mocks__/dataMocks/mockInfo'; import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import { mockWallet } from '../__mocks__/dataMocks/mockWallet'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component ShowUfvk - test', () => { //snapshot test diff --git a/__tests__/SyncReport.snapshot.tsx b/__tests__/SyncReport.snapshot.tsx index 93c14ad49..309a37931 100644 --- a/__tests__/SyncReport.snapshot.tsx +++ b/__tests__/SyncReport.snapshot.tsx @@ -15,22 +15,6 @@ import { mockTotalBalance } from '../__mocks__/dataMocks/mockTotalBalance'; import mockSyncingStatus from '../__mocks__/dataMocks/mockSyncingStatus'; import { mockNetInfo } from '../__mocks__/dataMocks/mockNetInfo'; -jest.mock('react-native', () => { - const RN = jest.requireActual('react-native'); - - RN.NativeModules.RPCModule = { - execute: jest.fn(() => '{}'), - getLatestBlock: jest.fn(() => '{}'), - walletExists: jest.fn(() => 'false'), - getValueTransfersList: jest.fn(() => '{ "value_transfers": [], "total": 0 }'), - setCryptoDefaultProvider: jest.fn(() => 'true'), - createNewWallet: jest.fn(() => '{ "seed": "seed phrase test", "birthday": 0 }'), - doSave: jest.fn(), - }; - - return RN; -}); - // test suite describe('Component SyncReport - test', () => { //snapshot test diff --git a/__tests__/__snapshots__/DetailLine.snapshot.tsx.snap b/__tests__/__snapshots__/DetailLine.snapshot.tsx.snap index 880e13b51..3cd3be0dd 100644 --- a/__tests__/__snapshots__/DetailLine.snapshot.tsx.snap +++ b/__tests__/__snapshots__/DetailLine.snapshot.tsx.snap @@ -19,7 +19,18 @@ exports[`Component DetailLine - test DetailLine children - snapshot 1`] = ` > label - + + Hello + `;