mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: add Deferred.race test (#10432)
This commit is contained in:
parent
ff8529696d
commit
45a05e038b
@ -45,4 +45,18 @@ describe('DeferredPromise', function () {
|
||||
}
|
||||
expect(caught).toBeTruthy();
|
||||
});
|
||||
it('Deferred.race should cancel timeout', async function () {
|
||||
const deferred = Deferred.create<void>();
|
||||
const deferredTimeout = Deferred.create<void>({
|
||||
message: 'Race did not stop timer',
|
||||
timeout: this.timeout() + 50,
|
||||
});
|
||||
await Promise.all([
|
||||
Deferred.race([deferred, deferredTimeout]),
|
||||
deferred.resolve(),
|
||||
]);
|
||||
|
||||
expect(deferredTimeout.value()).toBeInstanceOf(Error);
|
||||
expect(deferredTimeout.value()?.message).toContain('Timeout cleared');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user