Skip to content

Commit 74ebe32

Browse files
committed
Fixed random bug in mapGenerator tests
1 parent 367529a commit 74ebe32

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/mapGenerator.test.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,16 +580,17 @@ test('mapGenerator infinite sync operator', async () => {
580580
i += 1
581581
}
582582
}
583-
sleep(10).then(() => {
584-
shouldStop = true
585-
})
586583
const results = []
587584
for await (const el of mapGenerator(infiniteSyncGenerator(), async (el) => {
588585
await sleep(1)
586+
if (el === 10) {
587+
shouldStop = true
588+
}
589589
return el * 2
590590
})) {
591591
results.push(el)
592592
}
593+
expect(shouldStop).toStrictEqual(true)
593594
expect(results.length).toBeGreaterThanOrEqual(1)
594595
expect(results[0]).toStrictEqual(0)
595596
expect(results[1]).toStrictEqual(2)

0 commit comments

Comments
 (0)