fix(core): update
This commit is contained in:
26
test/test.ts
26
test/test.ts
@ -1,24 +1,38 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartlog from '../ts/index';
|
||||
|
||||
let defaultLogger: smartlog.Smartlog;
|
||||
let testConsoleLog: smartlog.ConsoleLog;
|
||||
let testSmartLog: smartlog.Smartlog;
|
||||
|
||||
tap.test('should produce a valid ConsoleLog instance', async () => {
|
||||
testConsoleLog = new smartlog.ConsoleLog();
|
||||
testConsoleLog.log('ok', 'this is ok');
|
||||
})
|
||||
|
||||
tap.test('should produce instance of Smartlog', async () => {
|
||||
defaultLogger = smartlog.defaultLogger;
|
||||
expect(defaultLogger).to.be.instanceOf(smartlog.Smartlog);
|
||||
testSmartLog = new smartlog.Smartlog({
|
||||
logContext: {
|
||||
environment: 'test',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone',
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'Lossless Cloud',
|
||||
containerName: 'testing'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should enable console logging', async () => {
|
||||
defaultLogger.enableConsole({
|
||||
testSmartLog.enableConsole({
|
||||
captureAll: true
|
||||
});
|
||||
console.log('this is a normal log that should be captured');
|
||||
console.log(new Error('hi there'));
|
||||
defaultLogger.log('info', 'this should only be printed once');
|
||||
testSmartLog.log('info', 'this should only be printed once');
|
||||
});
|
||||
|
||||
tap.test('should be able to log things', async () => {
|
||||
defaultLogger.log('silly', 'hi');
|
||||
testSmartLog.log('silly', 'hi');
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user