This repository has been archived by the owner on Jun 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
70 lines (53 loc) · 1.76 KB
/
test.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var assert = require('assert');
var sinon = require('sinon');
var bunyanLogger = require('./index.js');
var BunyanSpy = function() {
this.error = sinon.spy();
this.warn = sinon.spy();
this.info = sinon.spy();
this.debug = sinon.spy();
this.trace = sinon.spy();
}
describe("elasticsearch-bunyan-logger", function() {
beforeEach(function() {
var bunyan = new BunyanSpy();
var LoggingAdapter = bunyanLogger(bunyan);
this.loggerInstance = new LoggingAdapter();
this.bunyan = bunyan;
})
it("should log errors", function() {
this.loggerInstance.error('test error');
assert(this.bunyan.error.called);
assert(this.bunyan.error.calledWith('test error'));
})
it("should log warnings", function() {
this.loggerInstance.warning('test warning');
assert(this.bunyan.warn.called);
assert(this.bunyan.warn.calledWith('test warning'));
})
it("should log info", function() {
this.loggerInstance.info('test info');
assert(this.bunyan.info.called);
assert(this.bunyan.info.calledWith('test info'));
})
it("should log debug", function() {
this.loggerInstance.debug('test debug');
assert(this.bunyan.debug.called);
assert(this.bunyan.debug.calledWith('test debug'));
})
it("should log trace", function() {
this.loggerInstance.trace('method', 'url', 'body', 'responseBody', 'responseStatus');
assert(this.bunyan.trace.called);
assert(this.bunyan.trace.calledWith({
method: 'method',
requestUrl: 'url',
body: 'body',
responseBody: 'responseBody',
responseStatus: 'responseStatus'
}));
})
it("should have close() method implemented", function() {
// no asserts, if method is not implemented an error will be thrown
this.loggerInstance.close();
})
});