You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.7 KiB

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