@@ -5,6 +5,7 @@ import WalletAction from '../../../src/action/wallet';
55import NavAction from '../../../src/action/nav' ;
66import NotificationAction from '../../../src/action/notification' ;
77import * as logger from '../../../src/action/log' ;
8+ import { nap } from '../../../src/helper' ;
89import nock from 'nock' ;
910import 'isomorphic-fetch' ;
1011
@@ -23,6 +24,7 @@ describe('Action Wallet Unit Tests', () => {
2324 store = new Store ( ) ;
2425 require ( '../../../src/config' ) . RETRY_DELAY = 1 ;
2526 require ( '../../../src/config' ) . NOTIFICATION_DELAY = 1 ;
27+ require ( '../../../src/config' ) . RATE_DELAY = 1 ;
2628 grpc = sinon . createStubInstance ( GrpcAction ) ;
2729 db = sinon . createStubInstance ( AppStorage ) ;
2830 notification = sinon . createStubInstance ( NotificationAction ) ;
@@ -31,6 +33,7 @@ describe('Action Wallet Unit Tests', () => {
3133 } ) ;
3234
3335 afterEach ( ( ) => {
36+ clearTimeout ( wallet . tPollRate ) ;
3437 sandbox . restore ( ) ;
3538 } ) ;
3639
@@ -106,10 +109,10 @@ describe('Action Wallet Unit Tests', () => {
106109
107110 describe ( 'update()' , ( ) => {
108111 it ( 'should refresh balances, exchange rate and address' , async ( ) => {
109- sandbox . stub ( wallet , 'getExchangeRate ' ) ;
112+ sandbox . stub ( wallet , 'pollExchangeRate ' ) ;
110113 await wallet . update ( ) ;
111114 expect ( grpc . sendCommand , 'was called thrice' ) ;
112- expect ( wallet . getExchangeRate , 'was called once' ) ;
115+ expect ( wallet . pollExchangeRate , 'was called once' ) ;
113116 } ) ;
114117 } ) ;
115118
@@ -324,6 +327,15 @@ describe('Action Wallet Unit Tests', () => {
324327 } ) ;
325328 } ) ;
326329
330+ describe ( 'pollExchangeRate()' , ( ) => {
331+ it ( 'should call getExchangeRate' , async ( ) => {
332+ sandbox . stub ( wallet , 'getExchangeRate' ) ;
333+ await wallet . pollExchangeRate ( ) ;
334+ await nap ( 30 ) ;
335+ expect ( wallet . getExchangeRate . callCount , 'to be greater than' , 1 ) ;
336+ } ) ;
337+ } ) ;
338+
327339 describe ( 'getExchangeRate()' , ( ) => {
328340 it ( 'should get exchange rate' , async ( ) => {
329341 nock ( 'https://blockchain.info' )
0 commit comments