smartlog/test/test.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-10-30 17:56:26 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2018-06-05 18:48:14 +00:00
import * as smartlog from '../ts/index';
2018-01-28 03:31:06 +00:00
2020-06-08 18:51:11 +00:00
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');
2020-06-08 20:45:02 +00:00
});
2018-01-28 03:31:06 +00:00
2018-06-05 18:48:14 +00:00
tap.test('should produce instance of Smartlog', async () => {
2020-06-08 18:51:11 +00:00
testSmartLog = new smartlog.Smartlog({
logContext: {
environment: 'test',
runtime: 'node',
zone: 'gitzone',
company: 'Lossless GmbH',
companyunit: 'Lossless Cloud',
containerName: 'testing'
}
});
2018-01-28 03:31:06 +00:00
});
2018-06-05 18:48:14 +00:00
tap.test('should enable console logging', async () => {
2020-06-08 18:51:11 +00:00
testSmartLog.enableConsole({
2020-06-05 01:53:09 +00:00
captureAll: true
});
console.log('this is a normal log that should be captured');
console.log(new Error('hi there'));
2020-06-08 18:51:11 +00:00
testSmartLog.log('info', 'this should only be printed once');
2018-01-28 03:31:06 +00:00
});
2018-06-05 18:48:14 +00:00
tap.test('should be able to log things', async () => {
2020-06-08 18:51:11 +00:00
testSmartLog.log('silly', 'hi');
2018-01-28 03:31:06 +00:00
});
2020-06-08 20:39:40 +00:00
tap.test('should create a log group', async () => {
const logGroup = testSmartLog.createLogGroup('some cool transaction');
logGroup.log('info', 'this is logged from a log group');
2020-06-08 20:45:02 +00:00
});
2020-06-08 20:39:40 +00:00
2018-01-28 03:31:06 +00:00
tap.start();