11import { describe , expect , it } from 'vitest'
22import {
3- formatOutputForDisplay ,
43 formatOutputForChat ,
4+ formatOutputForDisplay ,
55 formatOutputForWorkflow ,
66 formatOutputRaw ,
77 formatOutputSafe ,
8- isOutputSafe
8+ isOutputSafe ,
99} from './format-output'
1010
1111describe ( 'format-output utilities' , ( ) => {
@@ -37,32 +37,22 @@ describe('format-output utilities', () => {
3737 data : {
3838 response : {
3939 message : {
40- content : 'Deep text'
41- }
42- }
43- }
40+ content : 'Deep text' ,
41+ } ,
42+ } ,
43+ } ,
4444 }
4545 expect ( formatOutputForDisplay ( nested ) ) . toBe ( 'Deep text' )
4646 } )
4747
4848 // Arrays
4949 it ( 'handles arrays of text objects' , ( ) => {
50- const arr = [
51- { text : 'Line 1' } ,
52- { text : 'Line 2' } ,
53- { content : 'Line 3' }
54- ]
50+ const arr = [ { text : 'Line 1' } , { text : 'Line 2' } , { content : 'Line 3' } ]
5551 expect ( formatOutputForDisplay ( arr ) ) . toBe ( 'Line 1 Line 2 Line 3' )
5652 } )
5753
5854 it ( 'handles mixed arrays' , ( ) => {
59- const mixed = [
60- 'String' ,
61- { text : 'Object text' } ,
62- 123 ,
63- null ,
64- { message : 'Message text' }
65- ]
55+ const mixed = [ 'String' , { text : 'Object text' } , 123 , null , { message : 'Message text' } ]
6656 expect ( formatOutputForDisplay ( mixed ) ) . toBe ( 'String Object text 123 Message text' )
6757 } )
6858
@@ -103,7 +93,7 @@ describe('format-output utilities', () => {
10393 const buffer = Buffer . from ( 'Hello Buffer' )
10494 expect ( formatOutputForDisplay ( buffer ) ) . toBe ( 'Hello Buffer' )
10595
106- const binaryBuffer = Buffer . from ( [ 0xFF , 0xFE , 0x00 , 0x01 ] )
96+ const binaryBuffer = Buffer . from ( [ 0xff , 0xfe , 0x00 , 0x01 ] )
10797 expect ( formatOutputForDisplay ( binaryBuffer ) ) . toBe ( '[Binary Data]' )
10898 } )
10999
@@ -118,10 +108,12 @@ describe('format-output utilities', () => {
118108 // Whitespace handling
119109 it ( 'preserves whitespace when requested' , ( ) => {
120110 const spaced = 'Line 1\n\nLine 2\t\tTabbed'
121- expect ( formatOutputForDisplay ( spaced , { preserveWhitespace : true } ) )
122- . toBe ( 'Line 1\n\nLine 2\t\tTabbed' )
123- expect ( formatOutputForDisplay ( spaced , { preserveWhitespace : false } ) )
124- . toBe ( 'Line 1 Line 2 Tabbed' )
111+ expect ( formatOutputForDisplay ( spaced , { preserveWhitespace : true } ) ) . toBe (
112+ 'Line 1\n\nLine 2\t\tTabbed'
113+ )
114+ expect ( formatOutputForDisplay ( spaced , { preserveWhitespace : false } ) ) . toBe (
115+ 'Line 1 Line 2 Tabbed'
116+ )
125117 } )
126118
127119 // Mode-specific formatting
@@ -148,7 +140,7 @@ describe('format-output utilities', () => {
148140 const customObj = {
149141 toString ( ) {
150142 return 'Custom String'
151- }
143+ } ,
152144 }
153145 expect ( formatOutputForDisplay ( customObj ) ) . toBe ( 'Custom String' )
154146 } )
@@ -157,7 +149,7 @@ describe('format-output utilities', () => {
157149 const obj = {
158150 func : ( ) => console . log ( 'test' ) ,
159151 undef : undefined ,
160- sym : Symbol ( 'test' )
152+ sym : Symbol ( 'test' ) ,
161153 }
162154 const result = formatOutputForDisplay ( obj , { mode : 'raw' } )
163155 expect ( result ) . toContain ( '[Function]' )
@@ -214,11 +206,14 @@ describe('format-output utilities', () => {
214206 describe ( 'error handling' , ( ) => {
215207 it ( 'handles errors gracefully' , ( ) => {
216208 // Create object that throws on property access
217- const evil = new Proxy ( { } , {
218- get ( ) {
219- throw new Error ( 'Evil object!' )
209+ const evil = new Proxy (
210+ { } ,
211+ {
212+ get ( ) {
213+ throw new Error ( 'Evil object!' )
214+ } ,
220215 }
221- } )
216+ )
222217
223218 const result = formatOutputForDisplay ( evil )
224219 expect ( result ) . toContain ( '[' )
@@ -241,29 +236,33 @@ describe('format-output utilities', () => {
241236 describe ( 'real-world LLM outputs' , ( ) => {
242237 it ( 'handles OpenAI format' , ( ) => {
243238 const openAIResponse = {
244- choices : [ {
245- message : {
246- content : 'AI response here'
247- }
248- } ]
239+ choices : [
240+ {
241+ message : {
242+ content : 'AI response here' ,
243+ } ,
244+ } ,
245+ ] ,
249246 }
250247 expect ( formatOutputForDisplay ( openAIResponse ) ) . toBe ( 'AI response here' )
251248 } )
252249
253250 it ( 'handles Anthropic format' , ( ) => {
254251 const anthropicResponse = {
255- content : [ {
256- text : 'Claude response'
257- } ]
252+ content : [
253+ {
254+ text : 'Claude response' ,
255+ } ,
256+ ] ,
258257 }
259258 expect ( formatOutputForDisplay ( anthropicResponse ) ) . toBe ( 'Claude response' )
260259 } )
261260
262261 it ( 'handles streaming chunks' , ( ) => {
263262 const chunk = {
264263 delta : {
265- content : 'Streaming text'
266- }
264+ content : 'Streaming text' ,
265+ } ,
267266 }
268267 expect ( formatOutputForDisplay ( chunk ) ) . toBe ( 'Streaming text' )
269268 } )
@@ -272,11 +271,11 @@ describe('format-output utilities', () => {
272271 const toolOutput = {
273272 result : {
274273 data : {
275- output : 'Tool execution result'
276- }
277- }
274+ output : 'Tool execution result' ,
275+ } ,
276+ } ,
278277 }
279278 expect ( formatOutputForDisplay ( toolOutput ) ) . toBe ( 'Tool execution result' )
280279 } )
281280 } )
282- } )
281+ } )
0 commit comments