File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
typescript-sdk/packages/client/src/agent/__tests__ Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,17 @@ jest.mock("uuid", () => ({
33
33
34
34
// Mock utils
35
35
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
+ } ,
37
47
} ) ) ;
38
48
39
49
// Mock the verify modules but NOT apply - we want to test against real defaultApplyEvents
@@ -1179,7 +1189,7 @@ describe("RunAgentSubscriber", () => {
1179
1189
expect ( mockSubscriber . onToolCallResultEvent ) . toHaveBeenCalledTimes ( 1 ) ;
1180
1190
expect ( mockSubscriber . onStateSnapshotEvent ) . toHaveBeenCalledTimes ( 1 ) ;
1181
1191
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
1183
1193
expect ( mockSubscriber . onNewToolCall ) . toHaveBeenCalledTimes ( 1 ) ;
1184
1194
} ) ;
1185
1195
} ) ;
You can’t perform that action at this time.
0 commit comments