Skip to content

Commit

Permalink
Improve test stability (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Dec 17, 2024
1 parent c6fa343 commit 719b91c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions tests/replayMode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,26 @@ describe('ReplayMode', () => {
range: 1,
});

await new Promise((resolve) => {
chart.onSymbolLoaded(() => {
console.log('Chart loaded');
resolve(true);
});
});
await new Promise((r) => chart.onSymbolLoaded(() => r(true)));

Check warning on line 79 in tests/replayMode.test.ts

View check run for this annotation

codefactor.io / CodeFactor

tests/replayMode.test.ts#L79

Return values from promise executor functions cannot be read. (no-promise-executor-return)
console.log('Chart loaded');

expect(chart.infos.full_name).toBe('BINANCE:BTCEUR');
});

it('steps forward automatically', async () => {
console.log('Play replay mode');
await chart.replayStart(200);
await chart.replayStart(100);

chart.onUpdate(() => {
console.log('Point ->', chart.periods[0].time);
});

await new Promise((resolve) => {
chart.onReplayEnd(() => {
console.log('Replay end');
resolve(true);
});
});
const msg = await Promise.race([
new Promise((r) => chart.onReplayEnd(() => r('Replay end'))),

Check warning on line 94 in tests/replayMode.test.ts

View check run for this annotation

codefactor.io / CodeFactor

tests/replayMode.test.ts#L94

Return values from promise executor functions cannot be read. (no-promise-executor-return)
new Promise((r) => setTimeout(() => r('Timeout'), 9000)),

Check warning on line 95 in tests/replayMode.test.ts

View check run for this annotation

codefactor.io / CodeFactor

tests/replayMode.test.ts#L95

Return values from promise executor functions cannot be read. (no-promise-executor-return)
]);

console.log(msg);

expect(
utils.calculateTimeGap(chart.periods),
Expand Down

0 comments on commit 719b91c

Please sign in to comment.