1 | "use strict";
|
---|
2 |
|
---|
3 | define(['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 | });
|
---|
14 |
|
---|
15 | afterEach(function() {
|
---|
16 | window.console = originalConsole;
|
---|
17 | });
|
---|
18 |
|
---|
19 | describe("If no level is saved", function() {
|
---|
20 | it("current level is the default level", function(log) {
|
---|
21 | log.setDefaultLevel("trace");
|
---|
22 | expect(log.getLevel()).toBe(log.levels.TRACE);
|
---|
23 | });
|
---|
24 | });
|
---|
25 |
|
---|
26 | describe("If a level is saved", function () {
|
---|
27 | beforeEach(function () {
|
---|
28 | testHelpers.setStoredLevel("trace");
|
---|
29 | });
|
---|
30 |
|
---|
31 | it("current level is the level which has been saved", function (log) {
|
---|
32 | log.setDefaultLevel("debug");
|
---|
33 | expect(log.getLevel()).toBe(log.levels.TRACE);
|
---|
34 | });
|
---|
35 | });
|
---|
36 |
|
---|
37 | describe("If the level is stored incorrectly", function() {
|
---|
38 | beforeEach(function() {
|
---|
39 | testHelpers.setLocalStorageStoredLevel("gibberish");
|
---|
40 | });
|
---|
41 |
|
---|
42 | it("current level is the default level", function(log) {
|
---|
43 | log.setDefaultLevel("debug");
|
---|
44 | expect(log.getLevel()).toBe(log.levels.DEBUG);
|
---|
45 | });
|
---|
46 | });
|
---|
47 | });
|
---|
48 | });
|
---|