mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
42 lines
977 B
TypeScript
42 lines
977 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { earlyZipReadableStreams } from "./early_zip_readable_streams.ts";
|
|
import { assertEquals } from "@std/assert";
|
|
|
|
Deno.test("earlyZipReadableStreams() handles short first", async () => {
|
|
const textStream = ReadableStream.from(["1", "2", "3"]);
|
|
const textStream2 = ReadableStream.from(["a", "b", "c", "d", "e"]);
|
|
|
|
const buf = await Array.fromAsync(
|
|
earlyZipReadableStreams(textStream, textStream2),
|
|
);
|
|
|
|
assertEquals(buf, [
|
|
"1",
|
|
"a",
|
|
"2",
|
|
"b",
|
|
"3",
|
|
"c",
|
|
]);
|
|
});
|
|
|
|
Deno.test("earlyZipReadableStreams() handles long first", async () => {
|
|
const textStream = ReadableStream.from(["a", "b", "c", "d", "e"]);
|
|
const textStream2 = ReadableStream.from(["1", "2", "3"]);
|
|
|
|
const buf = await Array.fromAsync(
|
|
earlyZipReadableStreams(textStream, textStream2),
|
|
);
|
|
|
|
assertEquals(buf, [
|
|
"a",
|
|
"1",
|
|
"b",
|
|
"2",
|
|
"c",
|
|
"3",
|
|
"d",
|
|
]);
|
|
});
|