added unit testing, and started implementing unit tests...phew
This commit is contained in:
48
node_modules/winston/test/transports/stream.test.js
generated
vendored
Normal file
48
node_modules/winston/test/transports/stream.test.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const writeable = require('../helpers').writeable;
|
||||
const { MESSAGE } = require('triple-beam');
|
||||
const os = require('os');
|
||||
const winston = require('../../');
|
||||
const split = require('split2');
|
||||
const assume = require('assume');
|
||||
|
||||
describe('Stream({ stream })', function () {
|
||||
it('should support objectMode streams', function (done) {
|
||||
const expected = {
|
||||
level: 'info',
|
||||
message: 'lolwut testing!'
|
||||
};
|
||||
|
||||
const stream = writeable(function (info) {
|
||||
assume(info).equals(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
const transport = new winston.transports.Stream({ stream });
|
||||
transport.log(expected);
|
||||
});
|
||||
|
||||
it('should support UTF8 encoding streams', function (done) {
|
||||
const expected = {
|
||||
level: 'info',
|
||||
message: 'lolwut testing!',
|
||||
[MESSAGE]: 'info: lolwut testing!'
|
||||
};
|
||||
|
||||
const stream = writeable(function (raw) {
|
||||
assume(raw.toString()).equals(`${expected[MESSAGE]}${os.EOL}`);
|
||||
done();
|
||||
}, false);
|
||||
|
||||
const transport = new winston.transports.Stream({ stream });
|
||||
transport.log(expected);
|
||||
});
|
||||
|
||||
it('should throw when not passed a stream', function () {
|
||||
assume(function () {
|
||||
const stream = new winston.transports.Stream()
|
||||
}).throws('options.stream is required.');''
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user