|
1 | | -import { describe, expect, test } from "bun:test" |
| 1 | +import { describe, expect } from "bun:test" |
2 | 2 | import { Effect } from "effect" |
3 | 3 | import { handlePtyInput } from "../../src/pty/input" |
| 4 | +import { it } from "../lib/effect" |
4 | 5 |
|
5 | 6 | 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) } |
9 | 11 |
|
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")) |
13 | 15 |
|
14 | | - expect(messages).toEqual(["ready", "hello"]) |
15 | | - }) |
| 16 | + expect(messages).toEqual(["ready", "hello"]) |
| 17 | + }), |
| 18 | + ) |
16 | 19 | }) |
0 commit comments