1 |
3a515b92
|
cagy
|
/* global MyCustomLogger, log */
|
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 |
|
|
});
|
20 |
|
|
|
21 |
|
|
it("successfully logs", function () {
|
22 |
|
|
window.console = { "log": jasmine.createSpy("log") };
|
23 |
|
|
|
24 |
|
|
MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
|
25 |
|
|
MyCustomLogger.info("test message");
|
26 |
|
|
|
27 |
|
|
expect(console.log).toHaveBeenCalledWith("test message");
|
28 |
|
|
});
|
29 |
|
|
});
|