source: trip-planner-front/node_modules/loglevel/test/default-level-test.js

Last change on this file was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[6a3a178]1"use strict";
2
3define(['test/test-helpers'], function(testHelpers) {
4 var describeIf = testHelpers.describeIf;
5 var it = testHelpers.itWithFreshLog;
6
7 var originalConsole = window.console;
8
9 describe("Setting default log level tests:", function() {
10
11 beforeEach(function() {
12 window.console = {"log" : jasmine.createSpy("console.log")};
13 this.addMatchers({
14 "toBeAtLevel" : testHelpers.toBeAtLevel,
15 "toBeTheStoredLevel" : testHelpers.toBeTheLevelStoredByLocalStorage
16 });
17
18 testHelpers.clearStoredLevels();
19 });
20
21 afterEach(function() {
22 window.console = originalConsole;
23 });
24
25 describe("If no level is saved", function() {
26 it("new level is always set", function(log) {
27 log.setDefaultLevel("trace");
28 expect(log).toBeAtLevel("trace");
29 });
30
31 it("level is not persisted", function(log) {
32 log.setDefaultLevel("debug");
33 expect("debug").not.toBeTheStoredLevel();
34 });
35 });
36
37 describe("If a level is saved", function () {
38 beforeEach(function () {
39 testHelpers.setStoredLevel("trace");
40 });
41
42 it("saved level is not modified", function (log) {
43 log.setDefaultLevel("debug");
44 expect(log).toBeAtLevel("trace");
45 });
46 });
47
48 describe("If the level is stored incorrectly", function() {
49 beforeEach(function() {
50 testHelpers.setLocalStorageStoredLevel("gibberish");
51 });
52
53 it("new level is set", function(log) {
54 log.setDefaultLevel("debug");
55 expect(log).toBeAtLevel("debug");
56 expect("debug").not.toBeTheStoredLevel();
57 });
58 });
[e29cc2e]59
60 describe("log.resetLevel() resets the log", function() {
61 it("to warn if no explicit default is set", function(log) {
62 log.setLevel("debug");
63 log.resetLevel();
64
65 expect(log).toBeAtLevel("warn");
66 });
67
68 it("to info if default is set to info", function(log) {
69 log.setDefaultLevel("info");
70 log.setLevel("debug");
71 log.resetLevel();
72
73 expect(log).toBeAtLevel("info");
74 });
75 });
[6a3a178]76 });
77});
Note: See TracBrowser for help on using the repository browser.