From ff64d69c27879612dd79c01cc8b0e23483e29f58 Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Sat, 10 Aug 2024 13:31:27 -0700 Subject: [PATCH] add large payload test --- src/turbo-stream.spec.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/turbo-stream.spec.ts b/src/turbo-stream.spec.ts index 882b767..ef4a55a 100644 --- a/src/turbo-stream.spec.ts +++ b/src/turbo-stream.spec.ts @@ -162,6 +162,19 @@ test("should encode and decode object", async () => { expect(output).toEqual(input); }); +test("should encode and decode large payload", async () => { + const input: unknown[] = []; + for (let i = 0; i < 10000; i++) { + input.push({ + [Math.random().toString(36).slice(2)]: Math.random() + .toString(36) + .slice(2), + }); + } + const output = await quickDecode(encode(input)); + expect(output).toEqual(input); +}); + test("should encode and decode object and dedupe object key, value, and promise value", async () => { const input = { foo: "bar", bar: "bar", baz: Promise.resolve("bar") }; const output = await quickDecode(encode(input)); @@ -421,9 +434,9 @@ test("should encode and decode objects with multiple promises resolving to the s test("should encode and decode objects with reused values", async () => { const input = { - foo: Promise.resolve({ use: 'baz' }), - bar: Promise.resolve('baz'), - data: Promise.resolve({ quux: 'quux' }), + foo: Promise.resolve({ use: "baz" }), + bar: Promise.resolve("baz"), + data: Promise.resolve({ quux: "quux" }), }; const decoded = await decode(encode(input));