2018-11-13 00:32:39 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
2018-03-01 23:13:09 +00:00
|
|
|
|
|
|
|
// preparation
|
2018-11-13 00:32:39 +00:00
|
|
|
import { ILogContext } from '@pushrocks/smartlog-interfaces';
|
|
|
|
import * as smartlog from '@pushrocks/smartlog';
|
2018-03-01 23:13:09 +00:00
|
|
|
|
|
|
|
const logContext: ILogContext = {
|
|
|
|
company: 'Lossless GmbH',
|
|
|
|
companyunit: 'Lossless.Cloud',
|
|
|
|
containerName: 'testContainer',
|
|
|
|
environment: 'staging',
|
2018-11-13 00:32:39 +00:00
|
|
|
runtime: 'chrome',
|
2020-07-10 00:37:18 +00:00
|
|
|
zone: 'servezone',
|
2018-11-13 00:32:39 +00:00
|
|
|
};
|
2018-03-01 23:13:09 +00:00
|
|
|
|
2020-07-10 00:28:54 +00:00
|
|
|
const logger = new smartlog.Smartlog({
|
2020-07-10 00:37:18 +00:00
|
|
|
logContext,
|
2020-07-10 00:28:54 +00:00
|
|
|
});
|
|
|
|
|
2018-03-01 23:13:09 +00:00
|
|
|
// import the module to test
|
2018-11-13 00:32:39 +00:00
|
|
|
import * as smartlogDestinationDevtools from '../ts/index';
|
2018-03-01 22:39:03 +00:00
|
|
|
|
2018-11-13 00:32:39 +00:00
|
|
|
let testDestination: smartlogDestinationDevtools.SmartlogDestinationDevtools;
|
2018-03-01 22:39:03 +00:00
|
|
|
|
|
|
|
tap.test('first test', async () => {
|
2018-11-13 00:32:39 +00:00
|
|
|
testDestination = new smartlogDestinationDevtools.SmartlogDestinationDevtools();
|
2018-03-01 22:39:03 +00:00
|
|
|
});
|
|
|
|
|
2018-03-01 23:13:09 +00:00
|
|
|
tap.test('should log a normal message', async () => {
|
2018-11-13 00:32:39 +00:00
|
|
|
testDestination.handleLog({
|
|
|
|
timestamp: Date.now(),
|
|
|
|
type: 'log',
|
|
|
|
context: logContext,
|
|
|
|
level: 'info',
|
2020-06-05 12:28:17 +00:00
|
|
|
message: 'wait, what? Hi, this is a message!',
|
|
|
|
correlation: {
|
|
|
|
id: '123',
|
2020-07-10 00:37:18 +00:00
|
|
|
type: 'none',
|
|
|
|
},
|
2018-11-13 00:32:39 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-01 23:13:09 +00:00
|
|
|
|
|
|
|
tap.test('should log a success message', async () => {
|
2018-11-13 00:32:39 +00:00
|
|
|
testDestination.handleLog({
|
|
|
|
timestamp: Date.now(),
|
|
|
|
context: logContext,
|
|
|
|
type: 'log',
|
|
|
|
level: 'info',
|
2020-06-05 12:28:17 +00:00
|
|
|
message: 'success: Hi, this is a message!',
|
|
|
|
correlation: {
|
|
|
|
id: '123',
|
2020-07-10 00:37:18 +00:00
|
|
|
type: 'none',
|
|
|
|
},
|
2018-11-13 00:32:39 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-01 23:13:09 +00:00
|
|
|
|
2018-03-01 22:39:03 +00:00
|
|
|
tap.start();
|