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

58 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2024-05-30 15:58:35 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
// preparation
2024-05-30 15:58:35 +00:00
import { type ILogContext } from '@push.rocks/smartlog-interfaces';
import * as smartlog from '@push.rocks/smartlog';
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
};
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
});
// import the module to test
2024-05-30 15:58:35 +00:00
import * as smartlogDestinationDevtools from '../ts/index.js';
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',
2020-07-10 00:37:18 +00:00
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',
2020-07-10 00:37:18 +00:00
type: 'none',
},
2018-11-13 00:32:39 +00:00
});
});
2018-03-01 22:39:03 +00:00
tap.start();