From eff3e432966f6bc9ed909ba22fcafc0978c924d7 Mon Sep 17 00:00:00 2001 From: Tareque Md Hanif Date: Sat, 11 Nov 2023 03:29:09 +0600 Subject: chore(cli): Migrate some unit tests to "Promise.withResolvers()" (#21128) Migrate to use `Promise.withResolvers()` instead of `deferred` in some of the tests in `cli/tests/unit/`. Issue: #21041 --- cli/tests/unit/fetch_test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cli/tests/unit/fetch_test.ts') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index c1f11093b..05c04f4ef 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -3,7 +3,6 @@ import { assert, assertEquals, assertRejects, - deferred, delay, fail, unimplemented, @@ -1260,13 +1259,13 @@ Deno.test( Deno.test( { permissions: { net: true } }, async function fetchNoServerReadableStreamBody() { - const done = deferred(); + const { promise, resolve } = Promise.withResolvers(); const body = new ReadableStream({ start(controller) { controller.enqueue(new Uint8Array([1])); setTimeout(() => { controller.enqueue(new Uint8Array([2])); - done.resolve(); + resolve(); }, 1000); }, }); @@ -1274,7 +1273,7 @@ Deno.test( await assertRejects(async () => { await fetch(nonExistentHostname, { body, method: "POST" }); }, TypeError); - await done; + await promise; }, ); -- cgit v1.2.3