1 |
|
2 | "use strict";
|
3 |
|
4 | describe("loglevel from a global <script> tag with a custom context", function () {
|
5 | it("is available globally", function () {
|
6 | expect(MyCustomLogger).not.toBeUndefined();
|
7 | });
|
8 |
|
9 | it("doesn't have log defined globally", function () {
|
10 | expect(window.log).not.toBeDefined();
|
11 | });
|
12 |
|
13 | it("allows setting the logging level", function () {
|
14 | MyCustomLogger.setLevel(MyCustomLogger.levels.TRACE);
|
15 | MyCustomLogger.setLevel(MyCustomLogger.levels.DEBUG);
|
16 | MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
|
17 | MyCustomLogger.setLevel(MyCustomLogger.levels.WARN);
|
18 | MyCustomLogger.setLevel(MyCustomLogger.levels.ERROR);
|
19 | expect().nothing();
|
20 | });
|
21 |
|
22 | it("successfully logs", function () {
|
23 | window.console = { "log": jasmine.createSpy("log") };
|
24 |
|
25 | MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
|
26 | MyCustomLogger.info("test message");
|
27 |
|
28 | expect(console.log).toHaveBeenCalledWith("test message");
|
29 | });
|
30 | });
|