@@ -26,6 +26,21 @@ test('POST /v1/chat/completions works with valid data', async () => {
2626 assert . strictEqual ( res . body . choices [ 0 ] . message . content , 'This is a mock response from the unified API.' ) ;
2727} ) ;
2828
29+ test ( 'POST /v1/chat/completions works with multimodal data' , async ( ) => {
30+ const res = await request ( app )
31+ . post ( '/v1/chat/completions' )
32+ . send ( {
33+ model : 'gpt-4' ,
34+ messages : [ { role : 'user' , content : [ { type : 'text' , text : 'Hello!' } ] } ]
35+ } ) ;
36+
37+ assert . strictEqual ( res . status , 200 ) ;
38+ assert . ok ( res . body . id . startsWith ( 'chatcmpl-' ) ) ;
39+ assert . ok ( res . body . id . length > 20 ) ;
40+ assert . strictEqual ( res . body . object , 'chat.completion' ) ;
41+ assert . strictEqual ( res . body . model , 'gpt-4' ) ;
42+ } ) ;
43+
2944test ( 'POST /v1/chat/completions fails without model' , async ( ) => {
3045 const res = await request ( app )
3146 . post ( '/v1/chat/completions' )
@@ -126,6 +141,7 @@ test('POST /v1/chat/completions fails with more than 1000 messages', async () =>
126141test ( 'isValidMessage validation helper' , ( ) => {
127142 const { isValidMessage } = require ( '../src/index.js' ) ;
128143 assert . strictEqual ( isValidMessage ( { role : 'user' , content : 'hello' } ) , true ) ;
144+ assert . strictEqual ( isValidMessage ( { role : 'user' , content : [ { type : 'text' , text : 'hello' } ] } ) , true ) ;
129145 assert . strictEqual ( isValidMessage ( null ) , false ) ;
130146 assert . strictEqual ( isValidMessage ( [ ] ) , false ) ;
131147 assert . strictEqual ( isValidMessage ( { role : 'user' } ) , false ) ;
0 commit comments