@@ -638,41 +638,43 @@ describe("DeepSeekHandler", () => {
638638 expect ( toolCallChunks . length ) . toBeGreaterThan ( 0 )
639639 expect ( toolCallChunks [ 0 ] . name ) . toBe ( "get_weather" )
640640
641- it ( "should pass abortSignal to chat.completions.create when provided in metadata" , async ( ) => {
642- const handler = new DeepSeekHandler ( { ...mockOptions , apiKey : "test-key" } )
643- const systemPrompt = "You are a helpful assistant."
644- const messages : Anthropic . Messages . MessageParam [ ] = [
645- { role : "user" , content : [ { type : "text" as const , text : "Hello!" } ] } ,
646- ]
647-
648- const controller = new AbortController ( )
649- const mockAbortSignal = controller . signal
650-
651- await handler . createMessage ( systemPrompt , messages , { abortSignal : mockAbortSignal } )
652- for await ( const _chunk of handler . createMessage ( systemPrompt , messages ) ) {
653- break
654- }
641+ describe ( "abortSignal support" , ( ) => {
642+ it ( "should pass abortSignal to chat.completions.create when provided in metadata" , async ( ) => {
643+ const handler = new DeepSeekHandler ( { ...mockOptions , apiKey : "test-key" } )
644+ const systemPrompt = "You are a helpful assistant."
645+ const messages : Anthropic . Messages . MessageParam [ ] = [
646+ { role : "user" , content : [ { type : "text" as const , text : "Hello!" } ] } ,
647+ ]
648+
649+ const controller = new AbortController ( )
650+ const mockAbortSignal = controller . signal
651+
652+ await handler . createMessage ( systemPrompt , messages , { taskId : "test" , abortSignal : mockAbortSignal } )
653+ for await ( const _chunk of handler . createMessage ( systemPrompt , messages ) ) {
654+ break
655+ }
655656
656- expect ( mockCreate ) . toHaveBeenCalled ( )
657- const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
658- expect ( callArgs . signal ) . toBe ( mockAbortSignal )
659- } )
657+ expect ( mockCreate ) . toHaveBeenCalled ( )
658+ const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
659+ expect ( callArgs . signal ) . toBe ( mockAbortSignal )
660+ } )
660661
661- it ( "should not include signal when abortSignal is not provided" , async ( ) => {
662- const handler = new DeepSeekHandler ( { ...mockOptions , apiKey : "test-key" } )
663- const systemPrompt = "You are a helpful assistant."
664- const messages : Anthropic . Messages . MessageParam [ ] = [
665- { role : "user" , content : [ { type : "text" as const , text : "Hello!" } ] } ,
666- ]
662+ it ( "should not include signal when abortSignal is not provided" , async ( ) => {
663+ const handler = new DeepSeekHandler ( { ...mockOptions , apiKey : "test-key" } )
664+ const systemPrompt = "You are a helpful assistant."
665+ const messages : Anthropic . Messages . MessageParam [ ] = [
666+ { role : "user" , content : [ { type : "text" as const , text : "Hello!" } ] } ,
667+ ]
667668
668- await handler . createMessage ( systemPrompt , messages )
669- for await ( const _chunk of handler . createMessage ( systemPrompt , messages ) ) {
670- break
671- }
669+ await handler . createMessage ( systemPrompt , messages )
670+ for await ( const _chunk of handler . createMessage ( systemPrompt , messages ) ) {
671+ break
672+ }
672673
673- expect ( mockCreate ) . toHaveBeenCalled ( )
674- const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
675- expect ( callArgs . signal ) . toBeUndefined ( )
674+ expect ( mockCreate ) . toHaveBeenCalled ( )
675+ const callArgs = mockCreate . mock . calls [ 0 ] [ 0 ]
676+ expect ( callArgs . signal ) . toBeUndefined ( )
677+ } )
676678 } )
677679 } )
678680 } )
0 commit comments