File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -98,3 +98,19 @@ test('Test Log.client()', () => {
9898 expect ( mockClientLoggingCallback ) . toHaveBeenCalled ( ) ;
9999 expect ( mockClientLoggingCallback ) . toHaveBeenCalledWith ( 'Test' , '' ) ;
100100} ) ;
101+
102+ test ( 'Test getContextEmail captures email per log line' , ( ) => {
103+ const mockCallback = jest . fn ( ) ;
104+ const LogWithEmail = new Logger ( {
105+ serverLoggingCallback : mockCallback ,
106+ clientLoggingCallback : jest . fn ( ) ,
107+ getContextEmail : ( ) => 'test@example.com' ,
108+ } ) ;
109+
110+ LogWithEmail . info ( 'Test message' , true ) ;
111+ expect ( mockCallback ) . toHaveBeenCalled ( ) ;
112+
113+ const packet = JSON . parse ( mockCallback . mock . calls [ 0 ] [ 1 ] . logPacket ) ;
114+ delete packet [ 0 ] . timestamp ;
115+ expect ( packet ) . toEqual ( [ { message : "[info] Test message" , parameters : '' , email : 'test@example.com' } ] ) ;
116+ } ) ;
You can’t perform that action at this time.
0 commit comments