Repository URL to install this package:
|
Version:
0.0.6 ▾
|
import { toMockLogger, LogMapKeyType } from '../loggerMock'
function expectEmpty(logger: ReturnType<typeof toMockLogger>) {
expect(logger.logMap.get('info').size).toEqual(0)
expect(logger.logMap.get('warn').size).toEqual(0)
expect(logger.logMap.get('error').size).toEqual(0)
expect(logger.logMap.get('debug').size).toEqual(0)
}
function testLogMethod(methodName: LogMapKeyType) {
const logger = toMockLogger()
logger[methodName]('eh')
const set = logger.logMap.get(methodName)
expect(set).toMatchSnapshot(methodName)
// console.log(methodName, set, set.size)
// @todo - is not working
// expect(set.size).toEqual(0)
}
describe('logger', () => {
it('should not have anything in it to begin', () => {
const logger = toMockLogger()
expectEmpty(logger)
})
it('should work for debug', () => {
testLogMethod('debug')
})
it('should work for info', () => {
testLogMethod('info')
})
it('should work for warn', () => {
testLogMethod('warn')
})
it('should work for error', () => {
testLogMethod('error')
})
it('should not leak', () => {
const logger = toMockLogger()
expectEmpty(logger)
})
})