MCPcopy Create free account
hub / github.com/denoland/std / testTransformStream

Function testTransformStream

streams/_test_utils.ts:11–26  ·  view source on GitHub ↗
(
  transform: TransformStream<T, U>,
  inputs: Iterable<T> | AsyncIterable<T>,
  outputs: Iterable<U> | AsyncIterable<U>,
)

Source from the content-addressed store, hash-verified

9 * @param outputs Expected output data
10 */
11export async function testTransformStream<T, U>(
12 transform: TransformStream<T, U>,
13 inputs: Iterable<T> | AsyncIterable<T>,
14 outputs: Iterable<U> | AsyncIterable<U>,
15) {
16 const reader = ReadableStream.from(inputs)
17 .pipeThrough(transform)
18 .getReader();
19 for await (const output of outputs) {
20 const { value, done } = await reader.read();
21 assertEquals(value, output);
22 assertEquals(done, false);
23 }
24 const f = await reader.read();
25 assert(f.done, `stream not done, value was: ${f.value}`);
26}

Calls 4

assertEqualsFunction · 0.90
assertFunction · 0.90
readMethod · 0.65
fromMethod · 0.45

Tested by

no test coverage detected