|
| 1 | +import { TestAppLogger } from '../testing/logging'; |
| 2 | +import { ApplicationLogLevel, CustomLogger } from './custom.logger'; |
| 3 | + |
| 4 | +describe('CustomLogger', () => { |
| 5 | + it('should be ok', () => { |
| 6 | + const logger = new CustomLogger(); |
| 7 | + expect(logger).toBeDefined(); |
| 8 | + expect(logger).toBeInstanceOf(CustomLogger); |
| 9 | + }); |
| 10 | + |
| 11 | + describe('ApplicationLogLevel', () => { |
| 12 | + it('should log the expected amount of messages with default logging enabled', () => { |
| 13 | + const logger = new TestAppLogger({ |
| 14 | + logLevel: ApplicationLogLevel.Default, |
| 15 | + }); |
| 16 | + logger.debug('hello world'); |
| 17 | + logger.verbose('hello world'); |
| 18 | + logger.log('hello world'); |
| 19 | + logger.warn('hello world'); |
| 20 | + logger.error('hello world'); |
| 21 | + logger.fatal('hello world'); |
| 22 | + expect(logger.printMessages).toHaveBeenCalledTimes(4); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should log the expected amount of messages with verbose logging enabled', () => { |
| 26 | + const logger = new TestAppLogger({ |
| 27 | + logLevel: ApplicationLogLevel.Verbose, |
| 28 | + }); |
| 29 | + logger.debug('hello world'); |
| 30 | + logger.verbose('hello world'); |
| 31 | + logger.log('hello world'); |
| 32 | + logger.warn('hello world'); |
| 33 | + logger.error('hello world'); |
| 34 | + logger.fatal('hello world'); |
| 35 | + expect(logger.printMessages).toHaveBeenCalledTimes(6); |
| 36 | + }); |
| 37 | + }); |
| 38 | +}); |
0 commit comments