diff options
author | 2023-01-09 03:26:16 -0800 | |
---|---|---|
committer | 2023-01-09 03:26:16 -0800 | |
commit | 3386afc0bc80974d78e4a9e03b2739655c646f66 (patch) | |
tree | fedd33341eb7fd89ef252f748cb276538175c9d8 /test/bun.js/socket/socket.test.ts | |
parent | 1a1014525b430c501085f5b0826b7714006422b9 (diff) | |
download | bun-3386afc0bc80974d78e4a9e03b2739655c646f66.tar.gz bun-3386afc0bc80974d78e4a9e03b2739655c646f66.tar.zst bun-3386afc0bc80974d78e4a9e03b2739655c646f66.zip |
Add test for Bun.listen throwing
Diffstat (limited to 'test/bun.js/socket/socket.test.ts')
-rw-r--r-- | test/bun.js/socket/socket.test.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/bun.js/socket/socket.test.ts b/test/bun.js/socket/socket.test.ts index f9218493f..200f9528c 100644 --- a/test/bun.js/socket/socket.test.ts +++ b/test/bun.js/socket/socket.test.ts @@ -33,6 +33,23 @@ it("should keep process alive only when active", async () => { ]); }); +it("listen() should throw connection error for invalid host", () => { + expect(() => { + const handlers = { + open(socket) { + socket.close(); + }, + data() {}, + }; + + Bun.listen({ + port: 4423, + hostname: "whatishtis.com", + socket: handlers, + }); + }).toThrow(); +}); + it("should reject on connection error, calling both connectError() and rejecting the promise", (done) => { var data = {}; connect({ |