import { Logger } from '../logger' ; export type MockedLogger = jest . Mocked < Logger > & { context : string [ ] ; } ; const createLoggerMock = ( context = [ ] ) => { const mockLog = { context , debug : jest . fn ( ) , error : jest . fn ( ) , fatal : jest . fn ( ) , info : jest . fn ( ) , log : jest . fn ( ) , trace : jest . fn ( ) , warn : jest . fn ( ) , get : jest . fn ( ) , } ; mockLog . get . mockImplementation ( ( ... ctx ) => ( { ctx , ... mockLog , } ) ) ; return mockLog ; } ; const clearLoggerMock = ( logger ) => { logger . debug . mockClear ( ) ; logger . info . mockClear ( ) ; logger . warn . mockClear ( ) ; logger . error . mockClear ( ) ; logger . trace . mockClear ( ) ; logger . fatal . mockClear ( ) ; logger . log . mockClear ( ) ; } ; const collectLoggerMock = ( logger ) => { return { debug : logger . debug . mock . calls , error : logger . error . mock . calls , fatal : logger . fatal . mock . calls , info : logger . info . mock . calls , log : logger . log . mock . calls , trace : logger . trace . mock . calls , warn : logger . warn . mock . calls , } ; } ; export const loggerMock = { create : createLoggerMock , clear : clearLoggerMock , collect : collectLoggerMock , } ;