Skip to content

Commit

Permalink
add large payload test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Aug 10, 2024
1 parent 48e55f6 commit ff64d69
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/turbo-stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit ff64d69

Please sign in to comment.