Files
probot/test/logger.test.ts
siddharth singh 8a12f83d0b Convert logger test to Typescript (#656)
* Convert logger test to Typescript

* Convert logger test to Typescript
2018-08-20 10:31:10 -04:00

30 lines
761 B
TypeScript

import { logger } from '../src/logger'
import { wrapLogger } from '../src/wrap-logger'
describe('logger', () => {
let output: string[]
beforeEach(() => {
output = []
logger.addStream({
level: 'trace',
stream: { write: (log: any) => output.push(log) } as any,
type: 'raw'
})
})
describe('child', () => {
test('sets attributes', () => {
const child = wrapLogger(logger).child({ id: '1234' })
child.debug('attributes will get added to this')
expect(output[0]).toHaveProperty('id', '1234')
})
test('allows setting the name', () => {
const child = wrapLogger(logger).child({ name: 'test' })
child.debug('hello')
expect(output[0]).toHaveProperty('name', 'test')
})
})
})