diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-25 16:04:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 16:04:14 -0400 |
commit | 5d7d9d64434bd0a9f1fcf391dabc51693e8cf1ae (patch) | |
tree | c217fac5a7d67ba326d456b2973d23a7c7b151d4 /cli/tests/unit/http_test.ts | |
parent | 66476efec5b92cd04c161d82cbb69992fed4eb0a (diff) |
chore(tests): improve unit tests using `deferred` (#11842)
Diffstat (limited to 'cli/tests/unit/http_test.ts')
-rw-r--r-- | cli/tests/unit/http_test.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index 201ca1269..680531876 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -803,8 +803,6 @@ unitTest( { perms: { net: true } }, async function httpServerIncompleteMessage() { const listener = Deno.listen({ port: 4501 }); - const def1 = deferred(); - const def2 = deferred(); const client = await Deno.connect({ port: 4501 }); await client.write(new TextEncoder().encode( @@ -830,23 +828,21 @@ unitTest( const errors: Error[] = []; - writeResponse() + const writePromise = writeResponse() .catch((error: Error) => { errors.push(error); - }) - .then(() => def1.resolve()); + }); const res = new Response(readable); - respondWith(res) - .catch((error: Error) => errors.push(error)) - .then(() => def2.resolve()); + const respondPromise = respondWith(res) + .catch((error: Error) => errors.push(error)); client.close(); await Promise.all([ - def1, - def2, + writePromise, + respondPromise, ]); listener.close(); |