Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit fb48991

Browse files
committed
Use new poll util to get exchange rate
1 parent fcc5bef commit fb48991

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/action/wallet.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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
/**

test/unit/action/wallet.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import WalletAction from '../../../src/action/wallet';
55
import NavAction from '../../../src/action/nav';
66
import NotificationAction from '../../../src/action/notification';
77
import * as logger from '../../../src/action/log';
8-
import { nap } from '../../../src/helper';
98
import nock from 'nock';
109
import '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

0 commit comments

Comments
 (0)