aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/socket/socket.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-09 03:26:16 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-09 03:26:16 -0800
commit3386afc0bc80974d78e4a9e03b2739655c646f66 (patch)
treefedd33341eb7fd89ef252f748cb276538175c9d8 /test/bun.js/socket/socket.test.ts
parent1a1014525b430c501085f5b0826b7714006422b9 (diff)
downloadbun-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.ts17
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({