1 | "use strict";
|
2 |
|
3 | define(['test/test-helpers'], function(testHelpers) {
|
4 | var it = testHelpers.itWithFreshLog;
|
5 |
|
6 | describe("Setting the methodFactory tests:", function() {
|
7 |
|
8 | it("methodFactory should be called once for each loggable level", function(log) {
|
9 | log.methodFactory = jasmine.createSpy("methodFactory");
|
10 |
|
11 | log.setLevel("trace");
|
12 | expect(log.methodFactory.calls.count()).toEqual(5);
|
13 | expect(log.methodFactory.calls.argsFor(0)).toEqual(["trace", 0, undefined]);
|
14 | expect(log.methodFactory.calls.argsFor(1)).toEqual(["debug", 0, undefined]);
|
15 | expect(log.methodFactory.calls.argsFor(2)).toEqual(["info", 0, undefined]);
|
16 | expect(log.methodFactory.calls.argsFor(3)).toEqual(["warn", 0, undefined]);
|
17 | expect(log.methodFactory.calls.argsFor(4)).toEqual(["error", 0, undefined]);
|
18 |
|
19 | log.setLevel("error");
|
20 | expect(log.methodFactory.calls.count()).toEqual(6);
|
21 | expect(log.methodFactory.calls.argsFor(5)).toEqual(["error", 4, undefined]);
|
22 | });
|
23 |
|
24 | it("functions returned by methodFactory should be used as logging functions", function(log) {
|
25 | var logFunction = function() {};
|
26 | log.methodFactory = function() { return logFunction; };
|
27 | log.setLevel("error");
|
28 |
|
29 | expect(log.warn).not.toEqual(logFunction);
|
30 | expect(log.error).toEqual(logFunction);
|
31 | });
|
32 |
|
33 | it("the third argument should be logger's name", function(log) {
|
34 | var logger = log.getLogger("newLogger");
|
35 | logger.methodFactory = jasmine.createSpy("methodFactory");
|
36 |
|
37 | logger.setLevel("error");
|
38 | expect(logger.methodFactory.calls.argsFor(0)).toEqual(["error", 4, "newLogger"]);
|
39 | });
|
40 |
|
41 | });
|
42 | });
|