smartlog-receiver/test/test.ts
2018-11-11 01:56:02 +01:00

43 lines
1.1 KiB
TypeScript

import { expect, tap } from '@pushrocks/tapbundle';
import * as smartlog from '@pushrocks/smartlog';
import * as smarthash from '@pushrocks/smarthash';
import * as smartlogReceiver from '../ts/index';
let testReceiver: smartlogReceiver.SmartlogReceiver;
let testSmartlog = smartlog.defaultLogger;
testSmartlog.enableConsole();
tap.test('should create a valid SmartlogReceiver', async () => {
testReceiver = new smartlogReceiver.SmartlogReceiver({
passphrase: 'hi',
smartlogInstance: testSmartlog,
validatorFunction: () => {
return true;
}
});
expect(testReceiver).to.be.instanceof(smartlogReceiver.SmartlogReceiver);
});
tap.test('should receive a message', async () => {
testReceiver.handleAuthenticatedLog({
auth: smarthash.sha256FromStringSync('hi'),
logPackage: {
timestamp: Date.now(),
context: {
company: 'Lossless GmbH',
companyunit: 'Lossless Cloud',
containerName: null,
environment: 'staging',
runtime: 'node',
zone: 'gitzone'
},
level: 'info',
type: 'log',
message: 'hi there'
}
});
})
tap.start();