2017-08-04 16:03:15 +02:00
|
|
|
'use strict';
|
|
|
|
|
2018-12-17 09:24:49 +01:00
|
|
|
const test = require('ava');
|
2019-04-30 21:14:23 +02:00
|
|
|
const logger = require('./logger');
|
2017-08-04 16:03:15 +02:00
|
|
|
|
|
|
|
test('should expose a setLoggerProvider function', t => {
|
|
|
|
t.true(logger.setLoggerProvider instanceof Function);
|
|
|
|
});
|
|
|
|
|
2017-08-05 15:38:55 +02:00
|
|
|
test('should require custom logger to implement info', t => {
|
|
|
|
const loggerImpl = {
|
|
|
|
debug: () => {},
|
|
|
|
warn: () => {},
|
|
|
|
error: () => {},
|
|
|
|
};
|
|
|
|
const provider = () => loggerImpl;
|
2020-04-13 22:53:06 +02:00
|
|
|
const error = t.throws(
|
|
|
|
() => {
|
|
|
|
logger.setLoggerProvider(provider)();
|
|
|
|
},
|
2020-04-14 22:29:11 +02:00
|
|
|
{ instanceOf: TypeError },
|
2020-04-13 22:53:06 +02:00
|
|
|
);
|
2017-08-05 15:38:55 +02:00
|
|
|
t.is(error.message, 'Logger must implement info');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should require custom logger to implement error', t => {
|
|
|
|
const loggerImpl = {
|
|
|
|
debug: () => {},
|
|
|
|
warn: () => {},
|
|
|
|
info: () => {},
|
|
|
|
};
|
|
|
|
const provider = () => loggerImpl;
|
2020-04-13 22:53:06 +02:00
|
|
|
const error = t.throws(
|
|
|
|
() => {
|
|
|
|
logger.setLoggerProvider(provider)();
|
|
|
|
},
|
2020-04-14 22:29:11 +02:00
|
|
|
{ instanceOf: TypeError },
|
2020-04-13 22:53:06 +02:00
|
|
|
);
|
2017-08-05 15:38:55 +02:00
|
|
|
t.is(error.message, 'Logger must implement error');
|
|
|
|
});
|