mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
test: add test for log level exclusiveness
This commit is contained in:
@@ -311,6 +311,38 @@ export class LoggerSpec {
|
||||
expect(spy).not.to.have.been.called();
|
||||
}
|
||||
|
||||
@test
|
||||
'log level exclusiveness'() {
|
||||
const warnSpy = LoggerSpec.sandbox.on(console, 'warn', () => {
|
||||
// noop WARN
|
||||
});
|
||||
const infoSpy = LoggerSpec.sandbox.on(console, 'info', () => {
|
||||
// noop INFO
|
||||
});
|
||||
const okSpy = LoggerSpec.sandbox.on(console, 'log', () => {
|
||||
// noop OK
|
||||
});
|
||||
|
||||
// only warn and info = warn + info = 4 + 1 = 5
|
||||
process.env.STAPPS_LOG_LEVEL = '5';
|
||||
|
||||
Logger.warn('Foo');
|
||||
Logger.info('Bar');
|
||||
Logger.ok('Baz');
|
||||
|
||||
expect(warnSpy).to.have.been.called();
|
||||
expect(warnSpy.__spy.calls[0][0]).to.contain('[WARN]');
|
||||
expect(warnSpy.__spy.calls[0][0]).to.contain('Foo');
|
||||
|
||||
expect(infoSpy).to.have.been.called();
|
||||
expect(infoSpy.__spy.calls[0][0]).to.contain('[INFO]');
|
||||
expect(infoSpy.__spy.calls[0][0]).to.contain('Bar');
|
||||
|
||||
expect(okSpy).to.not.have.been.called();
|
||||
|
||||
delete process.env.STAPPS_LOG_LEVEL;
|
||||
}
|
||||
|
||||
@test
|
||||
getLogLevel() {
|
||||
const savedProcess = process;
|
||||
|
||||
Reference in New Issue
Block a user