diff options
Diffstat (limited to 'test/js/node/net/node-net.test.ts')
-rw-r--r-- | test/js/node/net/node-net.test.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/js/node/net/node-net.test.ts b/test/js/node/net/node-net.test.ts index c38a4ac1a..efdff4bc5 100644 --- a/test/js/node/net/node-net.test.ts +++ b/test/js/node/net/node-net.test.ts @@ -357,14 +357,29 @@ describe("net.Socket write", () => { }); it("should handle connection error", done => { - var data = {}; + let errored = false; + // @ts-ignore - connect(55555, () => { + const socket = connect(55555, () => { done(new Error("Should not have connected")); - }).on("error", error => { + }); + + socket.on("error", error => { + if (errored) { + return done(new Error("Should not have errored twice")); + } + errored = true; expect(error).toBeDefined(); expect(error.name).toBe("SystemError"); expect(error.message).toBe("Failed to connect"); + }); + + socket.on("connect", () => { + done(new Error("Should not have connected")); + }); + + socket.on("close", () => { + expect(errored).toBe(true); done(); }); }); |