1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-06 22:35:51 -05:00

modify test to avoid op leaks

This commit is contained in:
Yoshiya Hinosawa 2024-11-12 20:59:04 +09:00
parent b276d38671
commit ace7f8bbd6
No known key found for this signature in database
GPG key ID: 9017DB4559488785

View file

@ -1075,22 +1075,33 @@ Deno.test("[node/https] node:https exports globalAgent", async () => {
);
});
Deno.test("[node/http] node:http request.setHeader(header, null) doesn't throw", () => {
Deno.test("[node/http] node:http request.setHeader(header, null) doesn't throw", async () => {
{
const req = http.request("http://localhost:4545/");
req.on("error", () => {});
const { promise, resolve } = Promise.withResolvers<void>();
const req = http.request("http://localhost:4545/", (res) => {
res.on("data", () => {});
res.on("end", () => {
resolve();
});
});
// @ts-expect-error - null is not a valid header value
req.setHeader("foo", null);
req.end();
req.destroy();
await promise;
}
{
const req = https.request("https://localhost:4545/");
req.on("error", () => {});
const { promise, resolve } = Promise.withResolvers<void>();
const req = http.request("http://localhost:4545/", (res) => {
res.on("data", () => {});
res.on("end", () => {
resolve();
});
});
// @ts-expect-error - null is not a valid header value
req.setHeader("foo", null);
req.end();
req.destroy();
await promise;
}
});