Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroaki SHIBUKI authored and Hiroaki SHIBUKI committed Mar 14, 2018
1 parent 8253829 commit 18365b2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index.test.js
Expand Up @@ -102,3 +102,27 @@ test('Logger output a log on the log level as configured.', t => {
});
t.pass();
});

test('Timestamp can be disiable with config.', t => {
const level = [
'trace',
'debug',
'info',
'warn',
'error',
'fatal',
];
const console = new Console();
const logger = new Logger({ level: 'trace', timestamp: false });
const timestamp = "2001-03-14T01:00:00.000Z";
logger.getTimestamp = () => timestamp;
logger.writeLog = console.log;

level.forEach(l => {
logger[l](`${l}.`);
t.is(console.last(), `{"level":"${l}","message":"${l}."}`);

logger[l](`${l}.`, { data1: `${l}#1`, data2: `${l}#2` });
t.is(console.last(), `{"level":"${l}","message":"${l}.","data1":"${l}#1","data2":"${l}#2"}`);
});
});

0 comments on commit 18365b2

Please sign in to comment.