deno.land / std@0.224.0 / streams / limited_transform_stream_test.ts

limited_transform_stream_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals, assertRejects } from "../assert/mod.ts";import { LimitedTransformStream } from "./limited_transform_stream.ts";
Deno.test("LimitedTransformStream", async function () { const r = ReadableStream.from([ "foo", "foo", "foo", "foo", "foo", "foo", ]).pipeThrough(new LimitedTransformStream(3));
const chunks = await Array.fromAsync(r); assertEquals(chunks.length, 3);});
Deno.test("LimitedTransformStream handles error", async function () { const r = ReadableStream.from([ "foo", "foo", "foo", "foo", "foo", "foo", ]).pipeThrough(new LimitedTransformStream(3, { error: true }));
await assertRejects(async () => await Array.fromAsync(r), RangeError);});
std

Version Info

Tagged at
6 months ago