aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/socket/socket.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/socket/socket.test.ts')
-rw-r--r--test/bun.js/socket/socket.test.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/bun.js/socket/socket.test.ts b/test/bun.js/socket/socket.test.ts
new file mode 100644
index 000000000..aff001c75
--- /dev/null
+++ b/test/bun.js/socket/socket.test.ts
@@ -0,0 +1,34 @@
+import { expect, it } from "bun:test";
+import { bunExe } from "../bunExe";
+import { spawn } from "bun";
+
+it("should keep process alive only when active", async () => {
+ const { exited, stdout, stderr } = spawn({
+ cmd: [ bunExe(), "echo.js" ],
+ cwd: import.meta.dir,
+ stdout: "pipe",
+ stdin: null,
+ stderr: "pipe",
+ env: {
+ BUN_DEBUG_QUIET_LOGS: 1,
+ },
+ });
+ expect(await exited).toBe(0);
+ expect(await new Response(stderr).text()).toBe("");
+ var lines = (await new Response(stdout).text()).split(/\r?\n/);
+ expect(lines.filter(function(line) {
+ return line.startsWith("[Server]");
+ })).toEqual([
+ "[Server] OPENED",
+ "[Server] GOT request",
+ "[Server] CLOSED",
+ ]);
+ expect(lines.filter(function(line) {
+ return line.startsWith("[Client]");
+ })).toEqual([
+ "[Client] OPENED",
+ "[Client] GOT response",
+ "[Client] ENDED",
+ "[Client] CLOSED",
+ ]);
+});