added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

View File

@ -0,0 +1,43 @@
'use strict';
const fs = require('fs');
const assert = require('assert');
const path = require('path');
const winston = require('../../lib/winston');
/* eslint-disable no-sync */
describe('winston/transports/file/createLogDir', function () {
const logDir = path.resolve(__dirname, '../fixtures/temp_logs');
beforeEach(function () {
fs.rmdirSync(logDir);
});
it('should create directory if it does not exist', function () {
winston.createLogger({
transports: [
new winston.transports.File({
filename: path.join(logDir, 'file.log')
})
]
});
assert(fs.existsSync(logDir));
});
it('should create directory if it does not exist when write to the stream', function () {
const streamfile = path.join(logDir, 'simple-stream.log');
const stream = fs.createWriteStream(streamfile);
winston.createLogger({
transports: [
new winston.transports.File({
stream: stream
})
]
});
assert(fs.existsSync(logDir));
});
});