This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -309,9 +309,7 @@ class WalletAction {
309309 * @return {Promise<undefined> }
310310 */
311311 async pollExchangeRate ( ) {
312- await this . getExchangeRate ( ) ;
313- clearTimeout ( this . tPollRate ) ;
314- this . tPollRate = setTimeout ( ( ) => this . pollExchangeRate ( ) , RATE_DELAY ) ;
312+ await poll ( ( ) => this . getExchangeRate ( ) , RATE_DELAY ) ;
315313 }
316314
317315 /**
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ 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' ;
98import nock from 'nock' ;
109import 'isomorphic-fetch' ;
1110
@@ -33,7 +32,6 @@ describe('Action Wallet Unit Tests', () => {
3332 } ) ;
3433
3534 afterEach ( ( ) => {
36- clearTimeout ( wallet . tPollRate ) ;
3735 sandbox . restore ( ) ;
3836 } ) ;
3937
@@ -357,11 +355,11 @@ describe('Action Wallet Unit Tests', () => {
357355 } ) ;
358356
359357 describe ( 'pollExchangeRate()' , ( ) => {
360- it ( 'should call getExchangeRate' , async ( ) => {
358+ it ( 'should poll getExchangeRate' , async ( ) => {
361359 sandbox . stub ( wallet , 'getExchangeRate' ) ;
360+ wallet . getExchangeRate . onSecondCall ( ) . resolves ( true ) ;
362361 await wallet . pollExchangeRate ( ) ;
363- await nap ( 30 ) ;
364- expect ( wallet . getExchangeRate . callCount , 'to be greater than' , 1 ) ;
362+ expect ( wallet . getExchangeRate , 'was called twice' ) ;
365363 } ) ;
366364 } ) ;
367365
You can’t perform that action at this time.
0 commit comments