File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,30 +76,26 @@ describe('ReplayMode', () => {
7676 range : 1 ,
7777 } ) ;
7878
79- await new Promise ( ( resolve ) => {
80- chart . onSymbolLoaded ( ( ) => {
81- console . log ( 'Chart loaded' ) ;
82- resolve ( true ) ;
83- } ) ;
84- } ) ;
79+ await new Promise ( ( r ) => chart . onSymbolLoaded ( ( ) => r ( true ) ) ) ;
80+ console . log ( 'Chart loaded' ) ;
8581
8682 expect ( chart . infos . full_name ) . toBe ( 'BINANCE:BTCEUR' ) ;
8783 } ) ;
8884
8985 it ( 'steps forward automatically' , async ( ) => {
9086 console . log ( 'Play replay mode' ) ;
91- await chart . replayStart ( 200 ) ;
87+ await chart . replayStart ( 100 ) ;
9288
9389 chart . onUpdate ( ( ) => {
9490 console . log ( 'Point ->' , chart . periods [ 0 ] . time ) ;
9591 } ) ;
9692
97- await new Promise ( ( resolve ) => {
98- chart . onReplayEnd ( ( ) => {
99- console . log ( 'Replay end' ) ;
100- resolve ( true ) ;
101- } ) ;
102- } ) ;
93+ const msg = await Promise . race ( [
94+ new Promise ( ( r ) => chart . onReplayEnd ( ( ) => r ( 'Replay end' ) ) ) ,
95+ new Promise ( ( r ) => setTimeout ( ( ) => r ( 'Timeout' ) , 9000 ) ) ,
96+ ] ) ;
97+
98+ console . log ( msg ) ;
10399
104100 expect (
105101 utils . calculateTimeGap ( chart . periods ) ,
You can’t perform that action at this time.
0 commit comments