Skip to content

Commit

Permalink
Merge pull request #76 from dmurvihill/fix-unhandled-rejection-in-tests
Browse files Browse the repository at this point in the history
Fix spurious warning from node in test output
  • Loading branch information
DirtyHairy committed Feb 1, 2024
2 parents ae43294 + 40fadc1 commit 6af938b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/withTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

Expand Down Expand Up @@ -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');
});
});

Expand Down

0 comments on commit 6af938b

Please sign in to comment.