Fake textStream that emits a fixed sequence of chunks.
(chunks: readonly string[])
| 47 | |
| 48 | /** Fake textStream that emits a fixed sequence of chunks. */ |
| 49 | function 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 | |
| 65 | describe("buildSideQuestionMessages", () => { |
| 66 | test("wraps the question in a <system-reminder> and exposes the transcript", () => { |
no test coverage detected