Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(logger): use global instance of console/null logger for tests
- Loading branch information
Showing
3 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const ENV_DEBUG = 'DEBUG'; | ||
|
||
export function isDebug() { | ||
return Reflect.has(process.env, 'DEBUG'); | ||
return Reflect.has(process.env, ENV_DEBUG); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expect } from 'chai'; | ||
import { ConsoleLogger, NullLogger } from 'noicejs'; | ||
|
||
import { getTestLogger, spyLogger } from '../src/Logger'; | ||
|
||
describe('logger utils', () => { | ||
describe('get test logger helper', () => { | ||
it('should return console logger in verbose mode', () => { | ||
expect(getTestLogger(true)).to.equal(ConsoleLogger.global); | ||
}); | ||
|
||
it('should return console logger in debug mode'); | ||
|
||
it('should return null logger otherwise', () => { | ||
expect(getTestLogger()).to.equal(NullLogger.global); | ||
}); | ||
}); | ||
|
||
describe('spy logger helper', () => { | ||
it('should return itself as a child', () => { | ||
const logger = spyLogger({}); | ||
expect(logger.child({})).to.equal(logger); | ||
}); | ||
}); | ||
}); |