MCPcopy
hub / github.com/coder/mux / fakeTextStream

Function fakeTextStream

src/node/services/sideQuestionService.test.ts:49–63  ·  view source on GitHub ↗

Fake textStream that emits a fixed sequence of chunks.

(chunks: readonly string[])

Source from the content-addressed store, hash-verified

47
48/** Fake textStream that emits a fixed sequence of chunks. */
49function fakeTextStream(chunks: readonly string[]) {
50 async function* gen() {
51 for (const c of chunks) {
52 // The await is purely formal — bun-test's async generator typing
53 // requires at least one await for `require-await`, and yielding to
54 // the microtask queue here also exercises the consumer's `for await`
55 // back-pressure handling the way a real provider stream would.
56 await Promise.resolve();
57 yield c;
58 }
59 }
60 return {
61 textStream: gen(),
62 } as unknown as ReturnType<typeof aiSdk.streamText>;
63}
64
65describe("buildSideQuestionMessages", () => {
66 test("wraps the question in a <system-reminder> and exposes the transcript", () => {

Callers 1

Calls 1

genFunction · 0.85

Tested by

no test coverage detected