-
Notifications
You must be signed in to change notification settings - Fork 1
/
factory.spec.js
57 lines (43 loc) · 1.3 KB
/
factory.spec.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
/*eslint-env mocha*/
"use strict";
const LoggerFactory = require("./factory");
const should = require("should");
const sinon = require("sinon");
describe("LoggerFactory", function() {
describe("#settings", function() {
it("should return settings by logger name", function() {
const f = new LoggerFactory();
should.exist(f.settings("abc"));
});
it("should return the same settings for the same name", function() {
const f = new LoggerFactory();
const s1 = f.settings("abc");
const s2 = f.settings("abc");
const s3 = f.settings("a");
s1.should.equal(s2);
s1.should.not.be.equal(s3);
});
});
describe("#get", function() {
it("should return logger by name", function() {
const f = new LoggerFactory();
should.exist(f.get("abc"));
});
it("should return the same by name", function() {
const f = new LoggerFactory();
const s1 = f.get("abc");
const s2 = f.get("abc");
const s3 = f.get("a");
s1.should.equal(s2);
s1.should.not.be.equal(s3);
});
});
it("bind logger callback to settings handle", function() {
const f = new LoggerFactory();
const s = f.settings("a");
s.handle = sinon.spy();
const l = f.get("a");
l.trace();
s.handle.called.should.be.true();
});
});