test(server): migrate pty websocket input test (#27348)
This commit is contained in:
parent
832aa94977
commit
e5319846ad
1 changed files with 12 additions and 9 deletions
|
|
@ -1,16 +1,19 @@
|
||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect } from "bun:test"
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import { handlePtyInput } from "../../src/pty/input"
|
import { handlePtyInput } from "../../src/pty/input"
|
||||||
|
import { it } from "../lib/effect"
|
||||||
|
|
||||||
describe("pty HttpApi websocket input", () => {
|
describe("pty HttpApi websocket input", () => {
|
||||||
test("does not forward invalid binary frames to the PTY handler", async () => {
|
it.effect("does not forward invalid binary frames to the PTY handler", () =>
|
||||||
const messages: Array<string | ArrayBuffer> = []
|
Effect.gen(function* () {
|
||||||
const handler = { onMessage: (message: string | ArrayBuffer) => messages.push(message) }
|
const messages: Array<string | ArrayBuffer> = []
|
||||||
|
const handler = { onMessage: (message: string | ArrayBuffer) => messages.push(message) }
|
||||||
|
|
||||||
await Effect.runPromise(handlePtyInput(handler, "ready"))
|
yield* handlePtyInput(handler, "ready")
|
||||||
await Effect.runPromise(handlePtyInput(handler, new Uint8Array([0xff, 0xfe, 0xfd])))
|
yield* handlePtyInput(handler, new Uint8Array([0xff, 0xfe, 0xfd]))
|
||||||
await Effect.runPromise(handlePtyInput(handler, new TextEncoder().encode("hello")))
|
yield* handlePtyInput(handler, new TextEncoder().encode("hello"))
|
||||||
|
|
||||||
expect(messages).toEqual(["ready", "hello"])
|
expect(messages).toEqual(["ready", "hello"])
|
||||||
})
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue