@@ -4,6 +4,7 @@ import AppStorage from '../../../src/action/app-storage';
44import WalletAction from '../../../src/action/wallet' ;
55import NavAction from '../../../src/action/nav' ;
66import NavActionMobile from '../../../src/action/nav-mobile' ;
7+ import FileAction from '../../../src/action/file-mobile' ;
78import NotificationAction from '../../../src/action/notification' ;
89import * as logger from '../../../src/action/log' ;
910import nock from 'nock' ;
@@ -18,7 +19,7 @@ describe('Action Wallet Unit Tests', () => {
1819 let wallet ;
1920 let nav ;
2021 let notification ;
21- let RNFS ;
22+ let file ;
2223
2324 beforeEach ( ( ) => {
2425 sandbox = sinon . createSandbox ( { } ) ;
@@ -31,11 +32,8 @@ describe('Action Wallet Unit Tests', () => {
3132 db = sinon . createStubInstance ( AppStorage ) ;
3233 notification = sinon . createStubInstance ( NotificationAction ) ;
3334 nav = sinon . createStubInstance ( NavAction ) ;
34- RNFS = {
35- DocumentDirectoryPath : '/foo/bar' ,
36- unlink : sinon . stub ( ) ,
37- } ;
38- wallet = new WalletAction ( store , grpc , db , nav , notification , RNFS ) ;
35+ file = sinon . createStubInstance ( FileAction ) ;
36+ wallet = new WalletAction ( store , grpc , db , nav , notification , file ) ;
3937 } ) ;
4038
4139 afterEach ( ( ) => {
@@ -308,18 +306,9 @@ describe('Action Wallet Unit Tests', () => {
308306 describe ( 'initWallet()' , ( ) => {
309307 it ( 'should init wallet' , async ( ) => {
310308 grpc . sendUnlockerCommand . withArgs ( 'InitWallet' ) . resolves ( ) ;
311- RNFS . unlink . resolves ( ) ;
312309 await wallet . initWallet ( { walletPassword : 'baz' , seedMnemonic : [ 'foo' ] } ) ;
313- expect (
314- RNFS . unlink ,
315- 'was called with' ,
316- '/foo/bar/data/chain/bitcoin/mainnet/wallet.db'
317- ) ;
318- expect (
319- RNFS . unlink ,
320- 'was called with' ,
321- '/foo/bar/data/chain/bitcoin/testnet/wallet.db'
322- ) ;
310+ expect ( file . deleteWalletDB , 'was called with' , 'mainnet' ) ;
311+ expect ( file . deleteWalletDB , 'was called with' , 'testnet' ) ;
323312 expect ( store . walletUnlocked , 'to be' , true ) ;
324313 expect ( grpc . sendUnlockerCommand , 'was called with' , 'InitWallet' , {
325314 walletPassword : Buffer . from ( 'baz' , 'utf8' ) ,
@@ -330,9 +319,9 @@ describe('Action Wallet Unit Tests', () => {
330319
331320 it ( 'should not delete wallet if RNFS not supported' , async ( ) => {
332321 grpc . sendUnlockerCommand . withArgs ( 'InitWallet' ) . resolves ( ) ;
333- delete wallet . _FS ;
322+ delete wallet . _file ;
334323 await wallet . initWallet ( { walletPassword : 'baz' , seedMnemonic : [ 'foo' ] } ) ;
335- expect ( RNFS . unlink , 'was not called' ) ;
324+ expect ( file . deleteWalletDB , 'was not called' ) ;
336325 expect ( store . walletUnlocked , 'to be' , true ) ;
337326 expect ( grpc . sendUnlockerCommand , 'was called with' , 'InitWallet' , {
338327 walletPassword : Buffer . from ( 'baz' , 'utf8' ) ,
0 commit comments