mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
b1b048d759
* initial commit * Update buffer_test.ts Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com> * remove brackets for classes --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
32 lines
815 B
TypeScript
32 lines
815 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("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);
|
|
});
|