chore(test): increase test coverage of WinstonLogger
Signed-off-by: Beth Griggs <bethanyngriggs@gmail.com>
This commit is contained in:
@@ -22,6 +22,17 @@ function msg(info: TransformableInfo): TransformableInfo {
|
||||
}
|
||||
|
||||
describe('WinstonLogger', () => {
|
||||
it('creates a winston logger instance with default options', () => {
|
||||
const logger = WinstonLogger.create({});
|
||||
expect(logger).toBeInstanceOf(WinstonLogger);
|
||||
});
|
||||
|
||||
it('creates a child logger', () => {
|
||||
const logger = WinstonLogger.create({});
|
||||
const childLogger = logger.child({ plugin: 'test-plugin' });
|
||||
expect(childLogger).toBeInstanceOf(WinstonLogger);
|
||||
});
|
||||
|
||||
it('redacter should redact and escape regex', () => {
|
||||
const redacter = WinstonLogger.redacter();
|
||||
const log = {
|
||||
@@ -47,4 +58,24 @@ describe('WinstonLogger', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('redacter should redact nested object', () => {
|
||||
const redacter = WinstonLogger.redacter();
|
||||
const log = {
|
||||
level: 'error',
|
||||
message: {
|
||||
nested: 'hello (world) from nested object',
|
||||
},
|
||||
};
|
||||
|
||||
redacter.add(['hello']);
|
||||
expect(redacter.format.transform(msg(log))).toEqual(
|
||||
msg({
|
||||
...log,
|
||||
message: {
|
||||
nested: '[REDACTED] (world) from nested',
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user