aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/net/node-net.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/node/net/node-net.test.ts')
-rw-r--r--test/js/node/net/node-net.test.ts30
1 files changed, 29 insertions, 1 deletions
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", () => {