From 40fadc1bdc10ed8cf41ff11becde68014e649228 Mon Sep 17 00:00:00 2001 From: Dolan Murvihill Date: Thu, 25 Jan 2024 13:25:31 -0800 Subject: [PATCH] Fix spurious warning from node in test output --- test/withTimeout.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/withTimeout.ts b/test/withTimeout.ts index 4a33408..1603655 100644 --- a/test/withTimeout.ts +++ b/test/withTimeout.ts @@ -119,11 +119,14 @@ suite('withTimeout', () => { test('waitForUnlock times out', async () => { mutex.acquire(); - const unlockPromise = mutex.waitForUnlock(); + let state = 'PENDING'; + mutex.waitForUnlock() + .then(() => { state = 'RESOLVED'; }) + .catch(() => { state = 'REJECTED'; }); await clock.tickAsync(120); - assert.rejects(unlockPromise, error); + assert.strictEqual(state, 'REJECTED'); }); }); @@ -255,11 +258,14 @@ suite('withTimeout', () => { test('waitForUnlock times out', async () => { semaphore.acquire(2); - const unlockPromise = semaphore.waitForUnlock(); + let state = 'PENDING'; - await clock.tickAsync(120); + semaphore.waitForUnlock() + .then(() => { state = 'RESOLVED'; }) + .catch(() => { state = 'REJECTED'; }); - assert.rejects(unlockPromise, error); + await clock.tickAsync(120); + assert.strictEqual(state, 'REJECTED'); }); });