2023-09-13 08:21:52 +00:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
import { assertEquals } from "../assert/assert_equals.ts";
|
|
|
|
import { toText } from "./to_text.ts";
|
|
|
|
|
|
|
|
Deno.test("[streams] toText", async () => {
|
2023-11-10 03:57:52 +00:00
|
|
|
const byteStream = ReadableStream.from(["hello", " js ", "fans"])
|
|
|
|
.pipeThrough(new TextEncoderStream());
|
2023-09-13 08:21:52 +00:00
|
|
|
|
|
|
|
assertEquals(await toText(byteStream), "hello js fans");
|
|
|
|
|
2023-11-10 03:57:52 +00:00
|
|
|
const stringStream = ReadableStream.from(["hello", " deno ", "world"]);
|
2023-09-13 08:21:52 +00:00
|
|
|
|
|
|
|
assertEquals(await toText(stringStream), "hello deno world");
|
|
|
|
});
|