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.

48 lines
1.5 KiB

4 years ago
  1. "use strict";
  2. define(['test/test-helpers'], function(testHelpers) {
  3. var describeIf = testHelpers.describeIf;
  4. var it = testHelpers.itWithFreshLog;
  5. var originalConsole = window.console;
  6. describe("Setting default log level tests:", function() {
  7. beforeEach(function() {
  8. window.console = {"log" : jasmine.createSpy("console.log")};
  9. });
  10. afterEach(function() {
  11. window.console = originalConsole;
  12. });
  13. describe("If no level is saved", function() {
  14. it("current level is the default level", function(log) {
  15. log.setDefaultLevel("trace");
  16. expect(log.getLevel()).toBe(log.levels.TRACE);
  17. });
  18. });
  19. describe("If a level is saved", function () {
  20. beforeEach(function () {
  21. testHelpers.setStoredLevel("trace");
  22. });
  23. it("current level is the level which has been saved", function (log) {
  24. log.setDefaultLevel("debug");
  25. expect(log.getLevel()).toBe(log.levels.TRACE);
  26. });
  27. });
  28. describe("If the level is stored incorrectly", function() {
  29. beforeEach(function() {
  30. testHelpers.setLocalStorageStoredLevel("gibberish");
  31. });
  32. it("current level is the default level", function(log) {
  33. log.setDefaultLevel("debug");
  34. expect(log.getLevel()).toBe(log.levels.DEBUG);
  35. });
  36. });
  37. });
  38. });