Skip to content

Commit e531984

Browse files
authored
test(server): migrate pty websocket input test (anomalyco#27348)
1 parent 832aa94 commit e531984

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import { describe, expect, test } from "bun:test"
1+
import { describe, expect } from "bun:test"
22
import { Effect } from "effect"
33
import { handlePtyInput } from "../../src/pty/input"
4+
import { it } from "../lib/effect"
45

56
describe("pty HttpApi websocket input", () => {
6-
test("does not forward invalid binary frames to the PTY handler", async () => {
7-
const messages: Array<string | ArrayBuffer> = []
8-
const handler = { onMessage: (message: string | ArrayBuffer) => messages.push(message) }
7+
it.effect("does not forward invalid binary frames to the PTY handler", () =>
8+
Effect.gen(function* () {
9+
const messages: Array<string | ArrayBuffer> = []
10+
const handler = { onMessage: (message: string | ArrayBuffer) => messages.push(message) }
911

10-
await Effect.runPromise(handlePtyInput(handler, "ready"))
11-
await Effect.runPromise(handlePtyInput(handler, new Uint8Array([0xff, 0xfe, 0xfd])))
12-
await Effect.runPromise(handlePtyInput(handler, new TextEncoder().encode("hello")))
12+
yield* handlePtyInput(handler, "ready")
13+
yield* handlePtyInput(handler, new Uint8Array([0xff, 0xfe, 0xfd]))
14+
yield* handlePtyInput(handler, new TextEncoder().encode("hello"))
1315

14-
expect(messages).toEqual(["ready", "hello"])
15-
})
16+
expect(messages).toEqual(["ready", "hello"])
17+
}),
18+
)
1619
})

0 commit comments

Comments
 (0)