aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/js/bun/net/socket.test.ts9
-rw-r--r--test/js/node/net/node-net.test.ts30
2 files changed, 34 insertions, 5 deletions
diff --git a/test/js/bun/net/socket.test.ts b/test/js/bun/net/socket.test.ts
index cf6625dc5..70173d31a 100644
--- a/test/js/bun/net/socket.test.ts
+++ b/test/js/bun/net/socket.test.ts
@@ -93,7 +93,7 @@ it("should reject on connection error, calling both connectError() and rejecting
expect(socket).toBeDefined();
expect(socket.data).toBe(data);
expect(error).toBeDefined();
- expect(error.name).toBe("SystemError");
+ expect(error.name).toBe("ECONNREFUSED");
expect(error.message).toBe("Failed to connect");
},
data() {
@@ -119,7 +119,7 @@ it("should reject on connection error, calling both connectError() and rejecting
() => done(new Error("Promise should reject instead")),
err => {
expect(err).toBeDefined();
- expect(err.name).toBe("SystemError");
+ expect(err.name).toBe("ECONNREFUSED");
expect(err.message).toBe("Failed to connect");
done();
@@ -164,8 +164,9 @@ it("should handle connection error", done => {
expect(socket).toBeDefined();
expect(socket.data).toBe(data);
expect(error).toBeDefined();
- expect(error.name).toBe("SystemError");
+ expect(error.name).toBe("ECONNREFUSED");
expect(error.message).toBe("Failed to connect");
+ expect((error as any).code).toBe("ECONNREFUSED");
done();
},
data() {
@@ -191,5 +192,5 @@ it("should handle connection error", done => {
});
it("should not leak memory when connect() fails again", async () => {
- await expectMaxObjectTypeCount(expect, "TCPSocket", 1, 100);
+ await expectMaxObjectTypeCount(expect, "TCPSocket", 2, 100);
});
diff --git a/test/js/node/net/node-net.test.ts b/test/js/node/net/node-net.test.ts
index efdff4bc5..109391af5 100644
--- a/test/js/node/net/node-net.test.ts
+++ b/test/js/node/net/node-net.test.ts
@@ -370,8 +370,36 @@ it("should handle connection error", done => {
}
errored = true;
expect(error).toBeDefined();
- expect(error.name).toBe("SystemError");
expect(error.message).toBe("Failed to connect");
+ expect((error as any).code).toBe("ECONNREFUSED");
+ });
+
+ socket.on("connect", () => {
+ done(new Error("Should not have connected"));
+ });
+
+ socket.on("close", () => {
+ expect(errored).toBe(true);
+ done();
+ });
+});
+
+it("should handle connection error (unix)", done => {
+ let errored = false;
+
+ // @ts-ignore
+ const socket = connect("loser", () => {
+ done(new Error("Should not have connected"));
+ });
+
+ socket.on("error", error => {
+ if (errored) {
+ return done(new Error("Should not have errored twice"));
+ }
+ errored = true;
+ expect(error).toBeDefined();
+ expect(error.message).toBe("Failed to connect");
+ expect((error as any).code).toBe("ENOENT");
});
socket.on("connect", () => {