source: trip-planner-front/node_modules/loglevel/test/method-factory-test.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[6a3a178]1"use strict";
2
3define(['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.length).toEqual(5);
13 expect(log.methodFactory.argsForCall[0]).toEqual(["trace", 0, undefined]);
14 expect(log.methodFactory.argsForCall[1]).toEqual(["debug", 0, undefined]);
15 expect(log.methodFactory.argsForCall[2]).toEqual(["info", 0, undefined]);
16 expect(log.methodFactory.argsForCall[3]).toEqual(["warn", 0, undefined]);
17 expect(log.methodFactory.argsForCall[4]).toEqual(["error", 0, undefined]);
18
19 log.setLevel("error");
20 expect(log.methodFactory.calls.length).toEqual(6);
21 expect(log.methodFactory.argsForCall[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.argsForCall[0]).toEqual(["error", 4, "newLogger"]);
39 });
40
41 });
42});
Note: See TracBrowser for help on using the repository browser.