From a9dd69f91ee4beaae587309ecca6b6c19fbfe122 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Fri, 6 Dec 2024 15:09:00 -0800 Subject: [PATCH] use a loop --- test/js/node/http/node-http.test.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index ac872f7aca..a65e3bbb4a 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -2484,15 +2484,13 @@ it("client should use chunked encoded if more than one write is called", async ( req.on("error", reject); // Write chunks to the request body - req.write("Hello"); - req.write(" "); - await sleep(100); - req.write("World"); - req.write(" "); - await sleep(100); - req.write("Chunked"); - req.write(" "); - await sleep(100); + + for (let i = 0; i < 4; i++) { + req.write("chunk"); + await sleep(50); + req.write(" "); + await sleep(50); + } req.write("BUN!"); // End the request and signal no more data will be sent req.end(); @@ -2500,7 +2498,7 @@ it("client should use chunked encoded if more than one write is called", async ( const chunks = await promise; expect(chunks.length).toBeGreaterThan(1); expect(chunks[chunks.length - 1]?.toString()).toEndWith("BUN!"); - expect(Buffer.concat(chunks).toString()).toBe("Hello World Chunked BUN!"); + expect(Buffer.concat(chunks).toString()).toBe("chunk ".repeat(4) + "BUN!"); }); it("client should use content-length if only one write is called", async () => {