Skip to content

Commit adf1c14

Browse files
committed
wip
1 parent 7d3416f commit adf1c14

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

typescript-sdk/packages/client/src/agent/__tests__/subscriber.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ jest.mock("uuid", () => ({
3333

3434
// Mock utils
3535
jest.mock("@/utils", () => ({
36-
structuredClone_: (obj: any) => JSON.parse(JSON.stringify(obj)),
36+
structuredClone_: (obj: any) => {
37+
if (obj === undefined) {
38+
return undefined;
39+
}
40+
try {
41+
return JSON.parse(JSON.stringify(obj));
42+
} catch (error) {
43+
// Fallback for cases where JSON.stringify/parse fails
44+
return obj;
45+
}
46+
},
3747
}));
3848

3949
// Mock the verify modules but NOT apply - we want to test against real defaultApplyEvents
@@ -1179,7 +1189,7 @@ describe("RunAgentSubscriber", () => {
11791189
expect(mockSubscriber.onToolCallResultEvent).toHaveBeenCalledTimes(1);
11801190
expect(mockSubscriber.onStateSnapshotEvent).toHaveBeenCalledTimes(1);
11811191
expect(mockSubscriber.onRunFinishedEvent).toHaveBeenCalledTimes(1);
1182-
expect(mockSubscriber.onNewMessage).toHaveBeenCalledTimes(2);
1192+
expect(mockSubscriber.onNewMessage).toHaveBeenCalledTimes(3); // 2 TEXT_MESSAGE_END + 1 TOOL_CALL_RESULT
11831193
expect(mockSubscriber.onNewToolCall).toHaveBeenCalledTimes(1);
11841194
});
11851195
});

0 commit comments

Comments
 (0)