smartlog-destination-local/test/test.ts
2023-07-09 17:38:18 +02:00

50 lines
1.4 KiB
TypeScript

import { tap, expect } from '@pushrocks/tapbundle';
import * as smartlogDesinationLocal from '../ts/index.js';
import type { ILogContext } from '@pushrocks/smartlog-interfaces';
const testLogContext: ILogContext = {
company: 'Lossless GmbH',
companyunit: 'Lossless.Cloud',
containerName: 'gitlabci',
environment: 'staging',
runtime: 'node',
zone: 'shipzone',
};
let testLocalInstance: smartlogDesinationLocal.DestinationLocal;
tap.test('should create a valid instance of DestinationLocal', async () => {
testLocalInstance = new smartlogDesinationLocal.DestinationLocal();
expect(testLocalInstance).toBeInstanceOf(smartlogDesinationLocal.DestinationLocal);
});
tap.test('.log(message) should print a blue Dir message', async () => {
testLocalInstance.handleLog({
timestamp: Date.now(),
type: 'log',
level: 'info',
context: testLogContext,
message: 'this is a info log message',
correlation: {
id: '123',
type: 'none',
},
});
});
tap.test('.logReduced(message) should only log two messages', async () => {
testLocalInstance.logReduced('Message 1');
testLocalInstance.logReduced('Message 1');
testLocalInstance.logReduced('Message 1');
testLocalInstance.logReduced('Message 1');
testLocalInstance.logReduced('Message 2');
testLocalInstance.logReduced('Message 2');
});
tap.test('.newLine(number) create specified amount of new lines', async () => {
testLocalInstance.newLine(1);
});
tap.start();