Skip to content

Commit

Permalink
add test for rejected promise as Record value
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Oct 25, 2023
1 parent fa120e9 commit becad0f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/turbo-stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ test("should encode and decode object with promises as values", async () => {
await decoded.done;
});

test("should encode and decode object with rejected promise", async () => {
const input = { foo: Promise.reject(new Error("bar")) };
const decoded = await decode(encode(input));
const value = decoded.value as typeof input;
expect(value.foo).toBeInstanceOf(Promise);
expect(value.foo).rejects.toEqual(await input.foo.catch((reason) => reason));
return decoded.done;
});

test("should encode and decode set with promises as values", async () => {
const prom = Promise.resolve("foo");
const input = new Set([prom, prom]);
Expand Down

0 comments on commit becad0f

Please sign in to comment.