Skip to content

Commit 719b91c

Browse files
committed
Improve test stability (2)
1 parent c6fa343 commit 719b91c

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

tests/replayMode.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)