@@ -4,7 +4,6 @@ import NavAction from '../../../src/action/nav';
44import NotificationAction from '../../../src/action/notification' ;
55import InfoAction from '../../../src/action/info' ;
66import * as logger from '../../../src/action/log' ;
7- import { nap } from '../../../src/helper' ;
87
98describe ( 'Action Info Unit Tests' , ( ) => {
109 let sandbox ;
@@ -27,7 +26,6 @@ describe('Action Info Unit Tests', () => {
2726 } ) ;
2827
2928 afterEach ( ( ) => {
30- clearTimeout ( info . t3 ) ;
3129 sandbox . restore ( ) ;
3230 } ) ;
3331
@@ -44,13 +42,12 @@ describe('Action Info Unit Tests', () => {
4442 expect ( store . blockHeight , 'to equal' , 'some-height' ) ;
4543 } ) ;
4644
47- it ( 'should only call once if chain is synced' , async ( ) => {
45+ it ( 'should return true if chain is synced' , async ( ) => {
4846 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
4947 synced_to_chain : true ,
5048 } ) ;
51- await info . getInfo ( ) ;
52- await nap ( 30 ) ;
53- expect ( grpc . sendCommand . callCount , 'to equal' , 1 ) ;
49+ const synced = await info . getInfo ( ) ;
50+ expect ( synced , 'to be' , true ) ;
5451 } ) ;
5552
5653 it ( 'should set percentSynced' , async ( ) => {
@@ -63,22 +60,30 @@ describe('Action Info Unit Tests', () => {
6360 expect ( store . percentSynced , 'to be within' , 0 , 1 ) ;
6461 } ) ;
6562
66- it ( 'should retry if chain is not synced' , async ( ) => {
63+ it ( 'should return false if chain is not synced' , async ( ) => {
6764 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
6865 synced_to_chain : false ,
6966 } ) ;
70- await info . getInfo ( ) ;
71- await nap ( 30 ) ;
72- expect ( grpc . sendCommand . callCount , 'to be greater than' , 1 ) ;
67+ const synced = await info . getInfo ( ) ;
68+ expect ( synced , 'to be' , false ) ;
7369 } ) ;
7470
75- it ( 'should retry on failure' , async ( ) => {
71+ it ( 'should log error on failure' , async ( ) => {
7672 grpc . sendCommand . rejects ( ) ;
7773 await info . getInfo ( ) ;
7874 expect ( logger . error , 'was called once' ) ;
7975 } ) ;
8076 } ) ;
8177
78+ describe ( 'pollInfo()' , ( ) => {
79+ it ( 'should poll wallet balances' , async ( ) => {
80+ sandbox . stub ( info , 'getInfo' ) ;
81+ info . getInfo . onSecondCall ( ) . resolves ( true ) ;
82+ await info . pollInfo ( ) ;
83+ expect ( info . getInfo , 'was called twice' ) ;
84+ } ) ;
85+ } ) ;
86+
8287 describe ( 'initLoaderSyncing()' , ( ) => {
8388 it ( 'should navigate straight to home if synced' , async ( ) => {
8489 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
@@ -99,7 +104,7 @@ describe('Action Info Unit Tests', () => {
99104 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
100105 synced_to_chain : true ,
101106 } ) ;
102- await nap ( 10 ) ;
107+ await info . getInfo ( ) ;
103108 expect ( nav . goHome , 'was called once' ) ;
104109 } ) ;
105110 } ) ;
0 commit comments