smartlog-destination-devtools/test/test.browser.ts

58 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-11-13 00:32:39 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
// preparation
2018-11-13 00:32:39 +00:00
import { ILogContext } from '@pushrocks/smartlog-interfaces';
import * as smartlog from '@pushrocks/smartlog';
const logContext: ILogContext = {
company: 'Lossless GmbH',
companyunit: 'Lossless.Cloud',
containerName: 'testContainer',
environment: 'staging',
2018-11-13 00:32:39 +00:00
runtime: 'chrome',
zone: 'servezone'
};
2020-07-10 00:28:54 +00:00
const logger = new smartlog.Smartlog({
logContext
});
// 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
});
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',
type: 'none'
}
2018-11-13 00:32:39 +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',
type: 'none'
}
2018-11-13 00:32:39 +00:00
});
});
2018-03-01 22:39:03 +00:00
tap.start();