logger.test.js 810 Bytes
/**
 * logger 工具类测试
 */

const test = require('ava');
const shelljs = require('shelljs');
const logger = require('../../library/logger');

// const today = () => {
//     let now = new Date();
//     let s = now.getFullYear();

//     if (now.getMonth() < 10) {
//         s += '-0' + now.getMonth();
//     } else {
//         s += now.getMonth();
//     }
//     if (now.getDay() < 10) {
//         s += '-0' + now.getDay();
//     } else {
//         s += now.getDay();
//     }
// };

test.cb('logger test', t => {
    shelljs.rm('-f', 'log/*.log.*');
    logger.info('xxx', () => {
        shelljs.ls('info.log.*').forEach(s => console.log('generate log file:' + s));
        t.end();
    });
});

test.after('clean test log file ', t => {
    shelljs.rm('-f', 'log/*.log.*');
    t.pass();
});