1- import { convertToOpenRouterChatMessages } from './convert-to-openrouter-chat-messages' ;
1+ import { describe , expect , it } from 'bun:test'
2+
3+ import { convertToOpenRouterChatMessages } from './convert-to-openrouter-chat-messages'
24
35describe ( 'user messages' , ( ) => {
46 it ( 'should convert image Uint8Array' , async ( ) => {
@@ -14,7 +16,7 @@ describe('user messages', () => {
1416 } ,
1517 ] ,
1618 } ,
17- ] ) ;
19+ ] )
1820
1921 expect ( result ) . toEqual ( [
2022 {
@@ -27,8 +29,8 @@ describe('user messages', () => {
2729 } ,
2830 ] ,
2931 } ,
30- ] ) ;
31- } ) ;
32+ ] )
33+ } )
3234
3335 it ( 'should convert image urls' , async ( ) => {
3436 const result = convertToOpenRouterChatMessages ( [
@@ -43,7 +45,7 @@ describe('user messages', () => {
4345 } ,
4446 ] ,
4547 } ,
46- ] ) ;
48+ ] )
4749
4850 expect ( result ) . toEqual ( [
4951 {
@@ -56,8 +58,8 @@ describe('user messages', () => {
5658 } ,
5759 ] ,
5860 } ,
59- ] ) ;
60- } ) ;
61+ ] )
62+ } )
6163
6264 it ( 'should convert messages with image base64' , async ( ) => {
6365 const result = convertToOpenRouterChatMessages ( [
@@ -72,7 +74,7 @@ describe('user messages', () => {
7274 } ,
7375 ] ,
7476 } ,
75- ] ) ;
77+ ] )
7678
7779 expect ( result ) . toEqual ( [
7880 {
@@ -85,20 +87,20 @@ describe('user messages', () => {
8587 } ,
8688 ] ,
8789 } ,
88- ] ) ;
89- } ) ;
90+ ] )
91+ } )
9092
9193 it ( 'should convert messages with only a text part to a string content' , async ( ) => {
9294 const result = convertToOpenRouterChatMessages ( [
9395 {
9496 role : 'user' ,
9597 content : [ { type : 'text' , text : 'Hello' } ] ,
9698 } ,
97- ] ) ;
99+ ] )
98100
99- expect ( result ) . toEqual ( [ { role : 'user' , content : 'Hello' } ] ) ;
100- } ) ;
101- } ) ;
101+ expect ( result ) . toEqual ( [ { role : 'user' , content : 'Hello' } ] )
102+ } )
103+ } )
102104
103105describe ( 'cache control' , ( ) => {
104106 it ( 'should pass cache control from system message provider metadata' , ( ) => {
@@ -112,16 +114,16 @@ describe('cache control', () => {
112114 } ,
113115 } ,
114116 } ,
115- ] ) ;
117+ ] )
116118
117119 expect ( result ) . toEqual ( [
118120 {
119121 role : 'system' ,
120122 content : 'System prompt' ,
121123 cache_control : { type : 'ephemeral' } ,
122124 } ,
123- ] ) ;
124- } ) ;
125+ ] )
126+ } )
125127
126128 it ( 'should pass cache control from user message provider metadata (single text part)' , ( ) => {
127129 const result = convertToOpenRouterChatMessages ( [
@@ -134,7 +136,7 @@ describe('cache control', () => {
134136 } ,
135137 } ,
136138 } ,
137- ] ) ;
139+ ] )
138140
139141 expect ( result ) . toEqual ( [
140142 {
@@ -147,8 +149,8 @@ describe('cache control', () => {
147149 } ,
148150 ] ,
149151 } ,
150- ] ) ;
151- } ) ;
152+ ] )
153+ } )
152154
153155 it ( 'should pass cache control from content part provider metadata (single text part)' , ( ) => {
154156 const result = convertToOpenRouterChatMessages ( [
@@ -166,7 +168,7 @@ describe('cache control', () => {
166168 } ,
167169 ] ,
168170 } ,
169- ] ) ;
171+ ] )
170172
171173 expect ( result ) . toEqual ( [
172174 {
@@ -179,8 +181,8 @@ describe('cache control', () => {
179181 } ,
180182 ] ,
181183 } ,
182- ] ) ;
183- } ) ;
184+ ] )
185+ } )
184186
185187 it ( 'should pass cache control from user message provider metadata (multiple parts)' , ( ) => {
186188 const result = convertToOpenRouterChatMessages ( [
@@ -200,7 +202,7 @@ describe('cache control', () => {
200202 } ,
201203 } ,
202204 } ,
203- ] ) ;
205+ ] )
204206
205207 expect ( result ) . toEqual ( [
206208 {
@@ -218,24 +220,24 @@ describe('cache control', () => {
218220 } ,
219221 ] ,
220222 } ,
221- ] ) ;
222- } ) ;
223+ ] )
224+ } )
223225
224226 it ( 'should pass cache control from user message provider metadata without cache control (single text part)' , ( ) => {
225227 const result = convertToOpenRouterChatMessages ( [
226228 {
227229 role : 'user' ,
228230 content : [ { type : 'text' , text : 'Hello' } ] ,
229231 } ,
230- ] ) ;
232+ ] )
231233
232234 expect ( result ) . toEqual ( [
233235 {
234236 role : 'user' ,
235237 content : 'Hello' ,
236238 } ,
237- ] ) ;
238- } ) ;
239+ ] )
240+ } )
239241
240242 it ( 'should pass cache control to multiple image parts from user message provider metadata' , ( ) => {
241243 const result = convertToOpenRouterChatMessages ( [
@@ -260,7 +262,7 @@ describe('cache control', () => {
260262 } ,
261263 } ,
262264 } ,
263- ] ) ;
265+ ] )
264266
265267 expect ( result ) . toEqual ( [
266268 {
@@ -283,8 +285,8 @@ describe('cache control', () => {
283285 } ,
284286 ] ,
285287 } ,
286- ] ) ;
287- } ) ;
288+ ] )
289+ } )
288290
289291 it ( 'should pass cache control to file parts from user message provider metadata' , ( ) => {
290292 const result = convertToOpenRouterChatMessages ( [
@@ -309,7 +311,7 @@ describe('cache control', () => {
309311 } ,
310312 } ,
311313 } ,
312- ] ) ;
314+ ] )
313315
314316 expect ( result ) . toEqual ( [
315317 {
@@ -330,8 +332,8 @@ describe('cache control', () => {
330332 } ,
331333 ] ,
332334 } ,
333- ] ) ;
334- } ) ;
335+ ] )
336+ } )
335337
336338 it ( 'should handle mixed part-specific and message-level cache control for multiple parts' , ( ) => {
337339 const result = convertToOpenRouterChatMessages ( [
@@ -371,7 +373,7 @@ describe('cache control', () => {
371373 } ,
372374 } ,
373375 } ,
374- ] ) ;
376+ ] )
375377
376378 expect ( result ) . toEqual ( [
377379 {
@@ -397,8 +399,8 @@ describe('cache control', () => {
397399 } ,
398400 ] ,
399401 } ,
400- ] ) ;
401- } ) ;
402+ ] )
403+ } )
402404
403405 it ( 'should pass cache control from individual content part provider metadata' , ( ) => {
404406 const result = convertToOpenRouterChatMessages ( [
@@ -421,7 +423,7 @@ describe('cache control', () => {
421423 } ,
422424 ] ,
423425 } ,
424- ] ) ;
426+ ] )
425427
426428 expect ( result ) . toEqual ( [
427429 {
@@ -438,8 +440,8 @@ describe('cache control', () => {
438440 } ,
439441 ] ,
440442 } ,
441- ] ) ;
442- } ) ;
443+ ] )
444+ } )
443445
444446 it ( 'should pass cache control from assistant message provider metadata' , ( ) => {
445447 const result = convertToOpenRouterChatMessages ( [
@@ -452,16 +454,16 @@ describe('cache control', () => {
452454 } ,
453455 } ,
454456 } ,
455- ] ) ;
457+ ] )
456458
457459 expect ( result ) . toEqual ( [
458460 {
459461 role : 'assistant' ,
460462 content : 'Assistant response' ,
461463 cache_control : { type : 'ephemeral' } ,
462464 } ,
463- ] ) ;
464- } ) ;
465+ ] )
466+ } )
465467
466468 it ( 'should pass cache control from tool message provider metadata' , ( ) => {
467469 const result = convertToOpenRouterChatMessages ( [
@@ -484,7 +486,7 @@ describe('cache control', () => {
484486 } ,
485487 } ,
486488 } ,
487- ] ) ;
489+ ] )
488490
489491 expect ( result ) . toEqual ( [
490492 {
@@ -493,8 +495,8 @@ describe('cache control', () => {
493495 content : JSON . stringify ( { answer : 42 } ) ,
494496 cache_control : { type : 'ephemeral' } ,
495497 } ,
496- ] ) ;
497- } ) ;
498+ ] )
499+ } )
498500
499501 it ( 'should support the alias cache_control field' , ( ) => {
500502 const result = convertToOpenRouterChatMessages ( [
@@ -507,16 +509,16 @@ describe('cache control', () => {
507509 } ,
508510 } ,
509511 } ,
510- ] ) ;
512+ ] )
511513
512514 expect ( result ) . toEqual ( [
513515 {
514516 role : 'system' ,
515517 content : 'System prompt' ,
516518 cache_control : { type : 'ephemeral' } ,
517519 } ,
518- ] ) ;
519- } ) ;
520+ ] )
521+ } )
520522
521523 it ( 'should support cache control on last message in content array' , ( ) => {
522524 const result = convertToOpenRouterChatMessages ( [
@@ -537,7 +539,7 @@ describe('cache control', () => {
537539 } ,
538540 ] ,
539541 } ,
540- ] ) ;
542+ ] )
541543
542544 expect ( result ) . toEqual ( [
543545 {
@@ -555,6 +557,6 @@ describe('cache control', () => {
555557 } ,
556558 ] ,
557559 } ,
558- ] ) ;
559- } ) ;
560- } ) ;
560+ ] )
561+ } )
562+ } )
0 commit comments