aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-03-03 14:24:12 -0800
committerGravatar GitHub <noreply@github.com> 2023-03-03 14:24:12 -0800
commit0f8f484e21e3ebafaf62370421f6296eaca262fe (patch)
tree8f5adeacb07ab24a20b7e8c764631e19244ec551 /test/bun.js
parent7e5dddd2fa3d940ebfff0ba2f24d1789f41212ee (diff)
downloadbun-0f8f484e21e3ebafaf62370421f6296eaca262fe.tar.gz
bun-0f8f484e21e3ebafaf62370421f6296eaca262fe.tar.zst
bun-0f8f484e21e3ebafaf62370421f6296eaca262fe.zip
Improve types for `node:http` (#2284)
* Document node:http * Fix test * Fix default * Fix default
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/node-http.test.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts
index 6ba619c3e..e0964edb0 100644
--- a/test/bun.js/node-http.test.ts
+++ b/test/bun.js/node-http.test.ts
@@ -83,10 +83,10 @@ describe("node:http", () => {
describe("request", () => {
let server;
let serverPort;
- let timer = null;
+ let timer: Timer | null = null;
beforeAll(() => {
server = createServer((req, res) => {
- const reqUrl = new URL(req.url, `http://${req.headers.host}`);
+ const reqUrl = new URL(req.url!, `http://${req.headers.host}`);
if (reqUrl.pathname) {
if (reqUrl.pathname === "/redirect") {
// Temporary redirect
@@ -148,6 +148,20 @@ describe("node:http", () => {
if (timer) clearTimeout(timer);
});
+ it("check for expected fields", done => {
+ const req = request({ host: "localhost", port: serverPort, method: "GET" }, res => {
+ res.on("end", () => {
+ done();
+ });
+ res.on("error", err => done(err));
+ });
+ expect(req.path).toEqual("/");
+ expect(req.method).toEqual("GET");
+ expect(req.host).toEqual("localhost");
+ expect(req.protocol).toEqual("http:");
+ req.end();
+ });
+
it("should make a standard GET request when passed string as first arg", done => {
const req = request(`http://localhost:${serverPort}`, res => {
let data = "";
@@ -510,7 +524,9 @@ describe("node:http", () => {
it("should noop keepSocketAlive", () => {
const agent = new Agent({ keepAlive: true });
+ // @ts-ignore
expect(agent.keepAlive).toBe(true);
+
agent.keepSocketAlive(dummyReq.socket);
});