diff --git a/test/diag/ComponentLogger.test.ts b/test/diag/ComponentLogger.test.ts index bbc25b1e..b9648c21 100644 --- a/test/diag/ComponentLogger.test.ts +++ b/test/diag/ComponentLogger.test.ts @@ -20,13 +20,9 @@ import { diag, DiagLogger, DiagLogLevel } from '../../src'; class SpyLogger implements DiagLogger { debug() {} - error() {} - info() {} - warn() {} - verbose() {} } @@ -41,6 +37,8 @@ describe('ComponentLogger', () => { logger = new SpyLogger(); sandbox.spy(logger); diag.setLogger(logger, DiagLogLevel.ALL); + // clean any messages up that might be there from the registration + sandbox.reset(); }); afterEach(() => { diff --git a/test/diag/logLevel.test.ts b/test/diag/logLevel.test.ts index d8df13d0..cfe86ce8 100644 --- a/test/diag/logLevel.test.ts +++ b/test/diag/logLevel.test.ts @@ -194,6 +194,7 @@ describe('LogLevelFilter DiagLogger', () => { it('diag.setLogger level and logger should log', () => { diag.setLogger(dummyLogger, map.level); + restoreCallHistory(); diag[fName](`${fName} called %s`, 'param1'); diagLoggerFunctions.forEach(lName => { if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { diff --git a/test/diag/logger.test.ts b/test/diag/logger.test.ts index 308c2603..c0efdcb6 100644 --- a/test/diag/logger.test.ts +++ b/test/diag/logger.test.ts @@ -38,6 +38,12 @@ describe('DiagLogger functions', () => { let dummyLogger: DiagLogger; + const restoreCallHistory = () => { + diagLoggerFunctions.forEach(fName => { + calledArgs[fName] = null; + }); + }; + beforeEach(() => { // mock dummyLogger = {} as DiagLogger; @@ -49,10 +55,7 @@ describe('DiagLogger functions', () => { }); afterEach(() => { - // restore - diagLoggerFunctions.forEach(fName => { - calledArgs[fName] = null; - }); + restoreCallHistory(); diag.disable(); }); @@ -75,6 +78,7 @@ describe('DiagLogger functions', () => { it(`diag should log with ${fName} message`, () => { diag.setLogger(dummyLogger, DiagLogLevel.ALL); + restoreCallHistory(); diag[fName](`${fName} called %s`, 'param1'); diagLoggerFunctions.forEach(lName => { if (fName === lName) {