Skip to content

Commit

Permalink
add tests for channels changes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincburns committed Jan 28, 2025
1 parent b455a58 commit d100e7e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libs/langgraph/src/tests/channels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,20 @@ describe("EphemeralValue with gaurd: false", () => {
expect(channel.get()).toBe(5);
});
});

it.each(
[LastValue, AnyValue, EphemeralValue].map((Channel) => ({
channel: Channel,
}))
)("$channel.name should handle undefined values", (Channel) => {
const channel = new Channel.channel<number | undefined>();
expect(() => {
channel.get();
}).toThrow(EmptyChannelError);
channel.update([undefined]);
expect(channel.get()).toBe(undefined);
channel.update([3]);
expect(channel.get()).toBe(3);
channel.update([undefined]);
expect(channel.get()).toBe(undefined);
});

0 comments on commit d100e7e

Please sign in to comment.