-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathtest.winston.js
45 lines (42 loc) · 1.39 KB
/
test.winston.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
/* globals describe, it */
/* eslint node/no-unpublished-require: ["error", {"allowModules": ["async", "chai", "winston"]}] */
const expect = require('chai').expect;
const winstonSupport = require('../lib/winston');
const winston = require('winston');
const runServer = require('../lib/testHelper').runServer;
describe('winston', () => {
describe('name', () => {
it('should be "fluent"', (done) => {
expect((new winstonSupport()).name).to.be.equal('fluent');
done();
});
});
describe('transport', () => {
it('should send log records', (done) => {
runServer({}, {}, (server, finish) => {
const logger = winston.createLogger({
format: winston.format.combine(
winston.format.splat(),
winston.format.simple()
),
transports: [
new winstonSupport({tag: 'debug', port: server.port})
]
});
logger.info('foo %s', 'bar', {x: 1});
setTimeout(() => {
finish((data) => {
expect(data[0].tag).to.be.equal('debug');
expect(data[0].data).exist;
expect(data[0].time).exist;
expect(data[0].data.message).to.be.equal('foo bar');
expect(data[0].data.level).to.be.equal('info');
expect(data[0].data.x).to.be.equal(1);
done();
});
}, 1000);
});
});
});
});