Skip to content

Commit

Permalink
feat(tests): add new test case for string concatenation using readabl…
Browse files Browse the repository at this point in the history
…eStreamToText

Added a new test case to the `iterable-to-readable-stream.spec.ts` file to cover the scenario of concatenating strings from an iterable into a single text. The test case utilizes the `readableStreamToText` utility from `bun` alongside the existing `iterableToReadableStream` function to achieve this. This addition ensures that the conversion of an iterable of string elements into a readable stream, followed by the concatenation of these streamed elements into a single string text, works as expected. The test is essential for verifying the functionality of streaming string data, particularly in scenarios where data is dynamically generated or fetched in parts.
  • Loading branch information
JonDotsoy committed Mar 10, 2024
1 parent 7632c33 commit 60bd694
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/iterable-to-readable-stream.spec.ts
@@ -1,6 +1,6 @@
import { test, expect } from "bun:test";
import { iterableToReadableStream } from "./iterable-to-readable-stream";
import { readableStreamToArray } from "bun";
import { readableStreamToArray, readableStreamToText } from "bun";

test("", async () => {
const iterable = [1, 2, 3];
Expand Down Expand Up @@ -37,3 +37,14 @@ test("", async () => {

expect(items).toEqual([1, 2, 3]);
});

test("", async () => {
const iterable = function* () {
yield "Hello ";
yield "world!";
};

const text = await readableStreamToText(iterableToReadableStream(iterable()));

expect(text).toEqual("Hello world!");
});

0 comments on commit 60bd694

Please sign in to comment.