MCPcopy Create free account
hub / github.com/anomalyco/opencode / assertClientEvent

Function assertClientEvent

packages/http-recorder/src/websocket.ts:53–62  ·  view source on GitHub ↗
(actual: string, expected: WebSocketEvent | undefined, index: number, asJson: boolean)

Source from the content-addressed store, hash-verified

51const jsonOrText = (value: string) => Option.match(decodeJson(value), { onNone: () => value, onSome: canonicalizeJson })
52
53const assertClientEvent = (actual: string, expected: WebSocketEvent | undefined, index: number, asJson: boolean) =>
54 Effect.sync(() => {
55 const matches =
56 expected?.direction === "client" &&
57 expected.kind === "text" &&
58 JSON.stringify(asJson ? jsonOrText(actual) : actual) ===
59 JSON.stringify(asJson ? jsonOrText(expected.body) : expected.body)
60 if (matches) return
61 throw new Error(`WebSocket client frame ${index + 1}: expected ${safeText(expected)}, received ${safeText(actual)}`)
62 })
63
64export const makeWebSocketExecutor = <E>(
65 options: WebSocketRecordReplayOptions<E>,

Callers 1

makeWebSocketExecutorFunction · 0.85

Calls 3

jsonOrTextFunction · 0.85
safeTextFunction · 0.85
syncMethod · 0.80

Tested by

no test coverage detected