2018-11-04 12:22:45 +00:00
|
|
|
import { tap, expect } from '@pushrocks/tapbundle';
|
|
|
|
import * as smartdelay from '@pushrocks/smartdelay';
|
2017-01-21 17:40:40 +00:00
|
|
|
|
2018-07-05 21:40:33 +00:00
|
|
|
import smartlogDesinationLocal = require('../ts/index');
|
2018-11-04 12:22:45 +00:00
|
|
|
import { ILogContext } from '@pushrocks/smartlog-interfaces';
|
2018-07-05 21:40:33 +00:00
|
|
|
|
|
|
|
let testLogContext: ILogContext = {
|
|
|
|
company: 'Lossless GmbH',
|
|
|
|
companyunit: 'Lossless.Cloud',
|
|
|
|
containerName: 'gitlabci',
|
|
|
|
environment: 'staging',
|
|
|
|
runtime: 'node',
|
|
|
|
zone: 'shipzone'
|
2018-11-04 12:22:45 +00:00
|
|
|
};
|
2018-07-05 21:40:33 +00:00
|
|
|
|
|
|
|
let testLocalInstance: smartlogDesinationLocal.DestinationLocal;
|
|
|
|
|
|
|
|
tap.test('should create a valid instance of DestinationLocal', async () => {
|
2018-11-04 12:22:45 +00:00
|
|
|
testLocalInstance = new smartlogDesinationLocal.DestinationLocal();
|
2018-07-05 21:40:33 +00:00
|
|
|
expect(testLocalInstance).to.be.instanceof(smartlogDesinationLocal.DestinationLocal);
|
2018-11-04 12:22:45 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
|
|
|
tap.test('.log(message) should print a blue Dir message', async () => {
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.handleLog({
|
2018-11-04 17:23:41 +00:00
|
|
|
timestamp: Date.now(),
|
2018-11-04 12:22:45 +00:00
|
|
|
type: 'log',
|
|
|
|
level: 'info',
|
|
|
|
context: testLogContext,
|
2018-07-05 21:40:33 +00:00
|
|
|
message: 'this is a info log message'
|
|
|
|
});
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
|
|
|
tap.test('.logReduced(message) should only log two messages', async () => {
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.logReduced('Message 1');
|
|
|
|
testLocalInstance.logReduced('Message 1');
|
|
|
|
testLocalInstance.logReduced('Message 1');
|
|
|
|
testLocalInstance.logReduced('Message 1');
|
|
|
|
testLocalInstance.logReduced('Message 2');
|
|
|
|
testLocalInstance.logReduced('Message 2');
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
|
|
|
tap.test('.newLine(number) create specified amount of new lines', async () => {
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.newLine(1);
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
|
|
|
tap.test('.ora(text,color) should display, update, and end a message', async () => {
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.ora.start('This is a test text', 'green');
|
2018-03-01 00:06:12 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.ora.text('updated text!');
|
2018-03-01 00:06:12 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
|
|
|
await smartdelay.delayFor(2000);
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.ora.stop();
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
|
|
|
tap.test('.ora(text,color) should display an error message when ended with error', async () => {
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.ora.start('This is another test text', 'green');
|
2018-03-01 00:06:12 +00:00
|
|
|
await smartdelay.delayFor(2000);
|
2018-07-05 21:40:33 +00:00
|
|
|
testLocalInstance.ora.stop();
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-04-21 21:38:51 +00:00
|
|
|
|
2018-03-03 12:57:55 +00:00
|
|
|
tap.start();
|