2022-08-18 14:39:34 -05:00
|
|
|
import pino from 'pino';
|
|
|
|
import { Writable } from 'stream';
|
2020-04-13 07:34:26 -05:00
|
|
|
|
2022-08-18 14:39:34 -05:00
|
|
|
import { buildPretty } from '../src';
|
2020-04-13 07:34:26 -05:00
|
|
|
|
2022-08-18 14:39:34 -05:00
|
|
|
describe('prettyFactory', () => {
|
|
|
|
const prettyfierOptions = {
|
|
|
|
messageKey: 'msg',
|
|
|
|
levelFirst: true,
|
|
|
|
prettyStamp: false,
|
|
|
|
colors: false,
|
|
|
|
};
|
|
|
|
test('should return a function', (done) => {
|
|
|
|
const pretty = buildPretty(prettyfierOptions);
|
|
|
|
const log = pino(
|
|
|
|
new Writable({
|
|
|
|
objectMode: true,
|
|
|
|
write(chunk, enc, cb) {
|
|
|
|
const formatted = pretty(JSON.parse(chunk));
|
|
|
|
expect(formatted).toBe('info --- test message ');
|
|
|
|
cb();
|
|
|
|
done();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
log.info({ test: 'test' }, '@{test} message');
|
2020-08-13 16:27:00 -05:00
|
|
|
});
|
2020-04-13 07:34:26 -05:00
|
|
|
});
|