@@ -729,3 +729,40 @@ describe('tail sampling', () => {
729729 expect ( errorSpy ) . toHaveBeenCalledTimes ( 0 )
730730 } )
731731} )
732+
733+ describe ( 'inset configuration' , ( ) => {
734+ let infoSpy : ReturnType < typeof vi . spyOn >
735+
736+ beforeEach ( ( ) => {
737+ infoSpy = vi . spyOn ( console , 'info' ) . mockImplementation ( ( ) => { } )
738+ } )
739+
740+ afterEach ( ( ) => {
741+ vi . restoreAllMocks ( )
742+ } )
743+
744+ it ( 'wraps wide event in $<inset> property when pretty is false' , ( ) => {
745+ initLogger ( { inset : 'evlog' , pretty : false } )
746+
747+ log . info ( { action : 'test' } )
748+
749+ expect ( infoSpy ) . toHaveBeenCalled ( )
750+ const [ [ output ] ] = infoSpy . mock . calls
751+ const parsed = JSON . parse ( output )
752+ expect ( parsed ) . toHaveProperty ( '$evlog' )
753+ expect ( parsed . $evlog ) . toHaveProperty ( 'level' , 'info' )
754+ expect ( parsed . $evlog ) . toHaveProperty ( 'action' , 'test' )
755+ } )
756+
757+ it ( 'pretty mode outputs correctly even when inset is configured' , ( ) => {
758+ const logSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
759+ initLogger ( { inset : 'evlog' , pretty : true } )
760+
761+ log . info ( { action : 'test' } )
762+
763+ expect ( logSpy ) . toHaveBeenCalled ( )
764+ const allOutput = logSpy . mock . calls . map ( c => c [ 0 ] ) . join ( '\n' )
765+ expect ( allOutput ) . toContain ( 'INFO' )
766+ expect ( allOutput ) . toMatch ( / a c t i o n : .* t e s t / )
767+ } )
768+ } )
0 commit comments