std/streams/limited_transform_stream_test.ts
Lino Le Van c46143f0ac
chore: update copyright year (#4046)
* chore: update copyright year

* fix

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-02 08:11:32 +11:00

32 lines
827 B
TypeScript

// 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("[streams] 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("[streams] LimitedTransformStream 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);
});