1- /* eslint-disable @typescript-eslint/no-explicit-any */
21/* eslint-disable @typescript-eslint/no-unused-vars */
32import { describe , it , expect , vi , beforeEach , afterEach } from 'vitest'
43import OpenAI from 'openai'
@@ -188,7 +187,7 @@ describe('OpenAIModel', () => {
188187
189188 describe ( 'stream' , ( ) => {
190189 describe ( 'validation' , ( ) => {
191- it ( 'throws error when messages array is empty (Issue #1) ' , async ( ) => {
190+ it ( 'throws error when messages array is empty' , async ( ) => {
192191 const mockClient = createMockClient ( async function * ( ) { } )
193192 const provider = new OpenAIModel ( { modelId : 'gpt-4o' , client : mockClient } )
194193
@@ -199,7 +198,7 @@ describe('OpenAIModel', () => {
199198 } ) . rejects . toThrow ( 'At least one message is required' )
200199 } )
201200
202- it ( 'validates system prompt is not empty (Issue #13) ' , async ( ) => {
201+ it ( 'validates system prompt is not empty' , async ( ) => {
203202 const createMock = vi . fn ( async function * ( ) {
204203 yield {
205204 choices : [ { delta : { role : 'assistant' , content : 'Hello' } , index : 0 } ] ,
@@ -226,7 +225,7 @@ describe('OpenAIModel', () => {
226225 expect ( events [ 0 ] ?. type ) . toBe ( 'modelMessageStartEvent' )
227226 } )
228227
229- it ( 'throws error for streaming with n > 1 (Issue #12) ' , async ( ) => {
228+ it ( 'throws error for streaming with n > 1' , async ( ) => {
230229 const mockClient = createMockClient ( async function * ( ) { } )
231230 const provider = new OpenAIModel ( {
232231 modelId : 'gpt-4o' ,
@@ -242,7 +241,7 @@ describe('OpenAIModel', () => {
242241 } ) . rejects . toThrow ( 'Streaming with n > 1 is not supported' )
243242 } )
244243
245- it ( 'throws error for tool spec without name or description (Issue #16) ' , async ( ) => {
244+ it ( 'throws error for tool spec without name or description' , async ( ) => {
246245 const mockClient = createMockClient ( async function * ( ) { } )
247246 const provider = new OpenAIModel ( { modelId : 'gpt-4o' , client : mockClient } )
248247 const messages : Message [ ] = [ { role : 'user' , content : [ { type : 'textBlock' , text : 'Hi' } ] } ]
@@ -256,22 +255,7 @@ describe('OpenAIModel', () => {
256255 } ) . rejects . toThrow ( 'Tool specification must have both name and description' )
257256 } )
258257
259- it ( 'throws error for empty assistant message (Issue #3)' , async ( ) => {
260- const mockClient = createMockClient ( async function * ( ) { } )
261- const provider = new OpenAIModel ( { modelId : 'gpt-4o' , client : mockClient } )
262- const messages : Message [ ] = [
263- { role : 'user' , content : [ { type : 'textBlock' , text : 'Hi' } ] } ,
264- { role : 'assistant' , content : [ ] } ,
265- ]
266-
267- await expect ( async ( ) => {
268- for await ( const _ of provider . stream ( messages ) ) {
269- // Should not reach here
270- }
271- } ) . rejects . toThrow ( 'Assistant message must have either text content or tool calls' )
272- } )
273-
274- it ( 'throws error for empty tool result content (Issue #4)' , async ( ) => {
258+ it ( 'throws error for empty tool result content' , async ( ) => {
275259 const mockClient = createMockClient ( async function * ( ) { } )
276260 const provider = new OpenAIModel ( { modelId : 'gpt-4o' , client : mockClient } )
277261 const messages : Message [ ] = [
@@ -288,7 +272,7 @@ describe('OpenAIModel', () => {
288272 } ) . rejects . toThrow ( 'Tool result for toolUseId "tool-123" has empty content' )
289273 } )
290274
291- it ( 'handles tool result with error status (Issue #5) ' , async ( ) => {
275+ it ( 'handles tool result with error status' , async ( ) => {
292276 const createMock = vi . fn ( async function * ( ) {
293277 yield {
294278 choices : [ { delta : { role : 'assistant' , content : 'Ok' } , index : 0 } ] ,
@@ -339,7 +323,7 @@ describe('OpenAIModel', () => {
339323 expect ( events [ 0 ] ?. type ) . toBe ( 'modelMessageStartEvent' )
340324 } )
341325
342- it ( 'throws error for circular reference in tool input (Issue #14) ' , async ( ) => {
326+ it ( 'throws error for circular reference in tool input' , async ( ) => {
343327 const mockClient = createMockClient ( async function * ( ) { } )
344328 const provider = new OpenAIModel ( { modelId : 'gpt-4o' , client : mockClient } )
345329
@@ -433,7 +417,7 @@ describe('OpenAIModel', () => {
433417 } )
434418 } )
435419
436- it ( 'emits modelMetadataEvent with usage information (Issue #11) ' , async ( ) => {
420+ it ( 'emits modelMetadataEvent with usage information' , async ( ) => {
437421 const mockClient = createMockClient ( async function * ( ) {
438422 yield {
439423 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -464,7 +448,7 @@ describe('OpenAIModel', () => {
464448 } )
465449 } )
466450
467- it ( 'handles usage with undefined properties (Issue #11) ' , async ( ) => {
451+ it ( 'handles usage with undefined properties' , async ( ) => {
468452 const mockClient = createMockClient ( async function * ( ) {
469453 yield {
470454 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -495,7 +479,7 @@ describe('OpenAIModel', () => {
495479 } )
496480 } )
497481
498- it ( 'filters out empty string content deltas (Issue #17) ' , async ( ) => {
482+ it ( 'filters out empty string content deltas' , async ( ) => {
499483 const mockClient = createMockClient ( async function * ( ) {
500484 yield {
501485 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -522,7 +506,7 @@ describe('OpenAIModel', () => {
522506 expect ( ( contentEvents [ 0 ] as any ) . delta . text ) . toBe ( 'Hello' )
523507 } )
524508
525- it ( 'prevents duplicate message start events (Issue #6) ' , async ( ) => {
509+ it ( 'prevents duplicate message start events' , async ( ) => {
526510 const mockClient = createMockClient ( async function * ( ) {
527511 yield {
528512 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -556,7 +540,7 @@ describe('OpenAIModel', () => {
556540 } )
557541
558542 describe ( 'tool calling' , ( ) => {
559- it ( 'handles tool use request with contentBlockStart and contentBlockStop events (Issue #7) ' , async ( ) => {
543+ it ( 'handles tool use request with contentBlockStart and contentBlockStop events' , async ( ) => {
560544 const mockClient = createMockClient ( async function * ( ) {
561545 yield {
562546 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -642,7 +626,7 @@ describe('OpenAIModel', () => {
642626 expect ( events [ 5 ] ) . toEqual ( { type : 'modelMessageStopEvent' , stopReason : 'toolUse' } )
643627 } )
644628
645- it ( 'handles multiple tool calls with correct contentBlockIndex (Issue #7, #8) ' , async ( ) => {
629+ it ( 'handles multiple tool calls with correct contentBlockIndex' , async ( ) => {
646630 const mockClient = createMockClient ( async function * ( ) {
647631 yield {
648632 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -698,7 +682,7 @@ describe('OpenAIModel', () => {
698682 expect ( stopEvents [ 1 ] ) . toEqual ( { type : 'modelContentBlockStopEvent' , contentBlockIndex : 1 } )
699683 } )
700684
701- it ( 'skips tool calls with invalid index (Issue #9) ' , async ( ) => {
685+ it ( 'skips tool calls with invalid index' , async ( ) => {
702686 const mockClient = createMockClient ( async function * ( ) {
703687 yield {
704688 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -746,7 +730,7 @@ describe('OpenAIModel', () => {
746730 warnSpy . mockRestore ( )
747731 } )
748732
749- it ( 'tool argument deltas can be reassembled into valid JSON (Issue #7) ' , async ( ) => {
733+ it ( 'tool argument deltas can be reassembled into valid JSON' , async ( ) => {
750734 const mockClient = createMockClient ( async function * ( ) {
751735 yield { choices : [ { delta : { role : 'assistant' } , index : 0 } ] }
752736 yield {
@@ -792,7 +776,7 @@ describe('OpenAIModel', () => {
792776 expect ( JSON . parse ( reassembled ) ) . toEqual ( { x : 10 , y : 20 } )
793777 } )
794778
795- it ( 'handles messages with both text and tool calls (Issue #16) ' , async ( ) => {
779+ it ( 'handles messages with both text and tool calls' , async ( ) => {
796780 const mockClient = createMockClient ( async function * ( ) {
797781 yield { choices : [ { delta : { role : 'assistant' } , index : 0 } ] }
798782 // Text content first
@@ -874,7 +858,7 @@ describe('OpenAIModel', () => {
874858 }
875859 } )
876860
877- it ( 'handles unknown stop reasons with warning (Issue #13) ' , async ( ) => {
861+ it ( 'handles unknown stop reasons with warning' , async ( ) => {
878862 const mockClient = createMockClient ( async function * ( ) {
879863 yield {
880864 choices : [ { delta : { role : 'assistant' } , index : 0 } ] ,
@@ -900,7 +884,7 @@ describe('OpenAIModel', () => {
900884 } )
901885
902886 describe ( 'API request formatting' , ( ) => {
903- it ( 'formats API request correctly with all options (Issue #14) ' , async ( ) => {
887+ it ( 'formats API request correctly with all options' , async ( ) => {
904888 let capturedRequest : any = null
905889 let callCount = 0
906890
@@ -971,7 +955,7 @@ describe('OpenAIModel', () => {
971955 } )
972956
973957 describe ( 'error handling' , ( ) => {
974- it ( 'throws ContextWindowOverflowError for structured error with code (Issue #10) ' , async ( ) => {
958+ it ( 'throws ContextWindowOverflowError for structured error with code' , async ( ) => {
975959 const mockClient = {
976960 chat : {
977961 completions : {
@@ -994,7 +978,7 @@ describe('OpenAIModel', () => {
994978 } ) . rejects . toThrow ( ContextWindowOverflowError )
995979 } )
996980
997- it ( 'throws ContextWindowOverflowError for error with message pattern (Issue #10) ' , async ( ) => {
981+ it ( 'throws ContextWindowOverflowError for error with message pattern' , async ( ) => {
998982 const mockClient = {
999983 chat : {
1000984 completions : {
@@ -1015,7 +999,7 @@ describe('OpenAIModel', () => {
1015999 } ) . rejects . toThrow ( ContextWindowOverflowError )
10161000 } )
10171001
1018- it ( 'throws ContextWindowOverflowError for APIError instance (Issue #5) ' , async ( ) => {
1002+ it ( 'throws ContextWindowOverflowError for APIError instance' , async ( ) => {
10191003 const mockClient = {
10201004 chat : {
10211005 completions : {
@@ -1064,7 +1048,7 @@ describe('OpenAIModel', () => {
10641048 } ) . rejects . toThrow ( 'Invalid API key' )
10651049 } )
10661050
1067- it ( 'handles stream interruption errors (Issue #12) ' , async ( ) => {
1051+ it ( 'handles stream interruption errors' , async ( ) => {
10681052 const mockClient = createMockClient ( async function * ( ) {
10691053 yield { choices : [ { delta : { role : 'assistant' } , index : 0 } ] }
10701054 yield { choices : [ { delta : { content : 'Hello' } , index : 0 } ] }
0 commit comments