@@ -70,20 +70,9 @@ describe("OpenAICompatibleHandler abort signal", () => {
7070 yield { type : "text-delta" , text : "Test response" }
7171 }
7272
73- function createMockStream ( yieldValue : any ) {
74- return {
75- fullStream : ( async function * ( ) {
76- yield yieldValue
77- } ) ( ) ,
78- usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
79- }
80- }
81-
82- const mockUsage = Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } )
83-
8473 mockStreamText . mockReturnValue ( {
8574 fullStream : mockFullStream ( ) ,
86- usage : mockUsage ,
75+ usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
8776 } )
8877
8978 await handler
@@ -95,7 +84,7 @@ describe("OpenAICompatibleHandler abort signal", () => {
9584
9685 expect ( mockStreamText ) . toHaveBeenCalledWith (
9786 expect . objectContaining ( {
98- signal : mockAbortSignal ,
87+ abortSignal : mockAbortSignal ,
9988 } ) ,
10089 )
10190 } )
@@ -105,20 +94,9 @@ describe("OpenAICompatibleHandler abort signal", () => {
10594 yield { type : "text-delta" , text : "Test response" }
10695 }
10796
108- function createMockStream ( yieldValue : any ) {
109- return {
110- fullStream : ( async function * ( ) {
111- yield yieldValue
112- } ) ( ) ,
113- usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
114- }
115- }
116-
117- const mockUsage = Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } )
118-
11997 mockStreamText . mockReturnValue ( {
12098 fullStream : mockFullStream ( ) ,
121- usage : mockUsage ,
99+ usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
122100 } )
123101
124102 await handler
@@ -129,7 +107,7 @@ describe("OpenAICompatibleHandler abort signal", () => {
129107
130108 expect ( mockStreamText ) . toHaveBeenCalledWith (
131109 expect . objectContaining ( {
132- signal : undefined ,
110+ abortSignal : undefined ,
133111 } ) ,
134112 )
135113 } )
@@ -139,27 +117,16 @@ describe("OpenAICompatibleHandler abort signal", () => {
139117 yield { type : "text-delta" , text : "Test response" }
140118 }
141119
142- function createMockStream ( yieldValue : any ) {
143- return {
144- fullStream : ( async function * ( ) {
145- yield yieldValue
146- } ) ( ) ,
147- usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
148- }
149- }
150-
151- const mockUsage = Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } )
152-
153120 mockStreamText . mockReturnValue ( {
154121 fullStream : mockFullStream ( ) ,
155- usage : mockUsage ,
122+ usage : Promise . resolve ( { inputTokens : 10 , outputTokens : 5 } ) ,
156123 } )
157124
158125 await handler . createMessage ( systemPrompt , messages ) . next ( )
159126
160127 expect ( mockStreamText ) . toHaveBeenCalledWith (
161128 expect . objectContaining ( {
162- signal : undefined ,
129+ abortSignal : undefined ,
163130 } ) ,
164131 )
165132 } )
@@ -183,14 +150,12 @@ describe("OpenAICompatibleHandler abort signal", () => {
183150 const stream = handler . createMessage ( systemPrompt , messages , {
184151 taskId : "test-task" ,
185152 abortSignal : mockAbortSignal ,
186- } )
153+ } )
187154
188155 await stream . next ( )
189-
190-
191156 // Verify the signal was captured before aborting
192157 expect ( capturedOptions ) . toBeDefined ( )
193- expect ( capturedOptions . signal ) . toBe ( mockAbortSignal )
158+ expect ( capturedOptions . abortSignal ) . toBe ( mockAbortSignal )
194159
195160 // Now abort - this should cause streamText to receive an aborted signal
196161 controller . abort ( )
@@ -222,7 +187,7 @@ describe("OpenAICompatibleHandler abort signal", () => {
222187 expect ( capturedOptions ) . toHaveProperty ( "model" )
223188 expect ( capturedOptions ) . toHaveProperty ( "system" , systemPrompt )
224189 expect ( capturedOptions ) . toHaveProperty ( "messages" )
225- expect ( capturedOptions ) . toHaveProperty ( "signal " , controller . signal )
190+ expect ( capturedOptions ) . toHaveProperty ( "abortSignal " , controller . signal )
226191 } )
227192 } )
228193} )
0 commit comments