summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/http_test.ts
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-05-17 01:20:32 +0200
committerGitHub <noreply@github.com>2023-05-17 01:20:32 +0200
commit867a6d303285cdffd060e6bb4b0e97de73925cfe (patch)
tree1c1f34b8a57fd6f7950d1b093a4b93f86480e247 /cli/tests/unit_node/http_test.ts
parenta22388bbd1377f75d3b873c59f6836cd12c2abe5 (diff)
refactor(node): reimplement http client (#19122)
This commit reimplements most of "node:http" client APIs using "ext/fetch". There is some duplicated code and two removed Node compat tests that will be fixed in follow up PRs. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tests/unit_node/http_test.ts')
-rw-r--r--cli/tests/unit_node/http_test.ts29
1 files changed, 3 insertions, 26 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts
index 556ba1684..08d2626d7 100644
--- a/cli/tests/unit_node/http_test.ts
+++ b/cli/tests/unit_node/http_test.ts
@@ -185,6 +185,7 @@ Deno.test("[node/http] server can respond with 101, 204, 205, 304 status", async
Deno.test("[node/http] request default protocol", async () => {
const promise = deferred<void>();
+ const promise2 = deferred<void>();
const server = http.createServer((_, res) => {
res.end("ok");
});
@@ -198,6 +199,7 @@ Deno.test("[node/http] request default protocol", async () => {
server.close();
});
assertEquals(res.statusCode, 200);
+ promise2.resolve();
},
);
req.end();
@@ -206,6 +208,7 @@ Deno.test("[node/http] request default protocol", async () => {
promise.resolve();
});
await promise;
+ await promise2;
});
Deno.test("[node/http] request with headers", async () => {
@@ -292,32 +295,6 @@ Deno.test("[node/http] http.IncomingMessage can be created without url", () => {
});
*/
-Deno.test("[node/http] set http.IncomingMessage.statusMessage", () => {
- // deno-lint-ignore no-explicit-any
- const message = new (http as any).IncomingMessageForClient(
- new Response(null, { status: 404, statusText: "Not Found" }),
- {
- encrypted: true,
- readable: false,
- remoteAddress: "foo",
- address() {
- return { port: 443, family: "IPv4" };
- },
- // deno-lint-ignore no-explicit-any
- end(_cb: any) {
- return this;
- },
- // deno-lint-ignore no-explicit-any
- destroy(_e: any) {
- return;
- },
- },
- );
- assertEquals(message.statusMessage, "Not Found");
- message.statusMessage = "boom";
- assertEquals(message.statusMessage, "boom");
-});
-
Deno.test("[node/http] send request with non-chunked body", async () => {
let requestHeaders: Headers;
let requestBody = "";