Added files for Juan
This commit is contained in:
34
ExACTRegressionScripts/node_modules/loglevel/test/.jshintrc
generated
vendored
Normal file
34
ExACTRegressionScripts/node_modules/loglevel/test/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"curly": true,
|
||||
"globalstrict": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"es3": true,
|
||||
"globals": {
|
||||
"window": true,
|
||||
"console": true,
|
||||
"define": false,
|
||||
"require": false,
|
||||
"exports": false,
|
||||
"_": false,
|
||||
"afterEach": false,
|
||||
"beforeEach": false,
|
||||
"confirm": false,
|
||||
"context": false,
|
||||
"describe": false,
|
||||
"xdescribe": false,
|
||||
"expect": false,
|
||||
"it": false,
|
||||
"jasmine": false,
|
||||
"waitsFor": false,
|
||||
"runs": false,
|
||||
"Symbol": false
|
||||
}
|
||||
}
|
||||
101
ExACTRegressionScripts/node_modules/loglevel/test/console-fallback-test.js
generated
vendored
Normal file
101
ExACTRegressionScripts/node_modules/loglevel/test/console-fallback-test.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
|
||||
function consoleLogIsCalledBy(log, methodName) {
|
||||
it(methodName + " calls console.log", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log[methodName]("Log message for call to " + methodName);
|
||||
expect(console.log.calls.count()).toEqual(1);
|
||||
});
|
||||
}
|
||||
|
||||
function mockConsole() {
|
||||
return {"log" : jasmine.createSpy("console.log")};
|
||||
}
|
||||
|
||||
define(['../lib/loglevel', 'test/test-helpers'], function(log, testHelpers) {
|
||||
var originalConsole = window.console;
|
||||
|
||||
describe("Fallback functionality:", function() {
|
||||
describe("with no console present", function() {
|
||||
beforeEach(function() {
|
||||
window.console = undefined;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
it("silent method calls are allowed", function() {
|
||||
var result = log.setLevel(log.levels.SILENT);
|
||||
log.trace("hello");
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it("setting an active level gently returns an error string", function() {
|
||||
var result = log.setLevel(log.levels.TRACE);
|
||||
expect(result).toEqual("No console available for logging");
|
||||
});
|
||||
|
||||
it("active method calls are allowed, once the active setLevel fails", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log.trace("hello");
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
describe("if a console later appears", function () {
|
||||
it("logging is re-enabled and works correctly when next used", function () {
|
||||
log.setLevel(log.levels.WARN);
|
||||
|
||||
window.console = mockConsole();
|
||||
log.error("error");
|
||||
|
||||
expect(window.console.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("logging is re-enabled but does nothing when used at a blocked level", function () {
|
||||
log.setLevel(log.levels.WARN);
|
||||
|
||||
window.console = mockConsole();
|
||||
log.trace("trace");
|
||||
|
||||
expect(window.console.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("changing level works correctly from that point", function () {
|
||||
window.console = mockConsole();
|
||||
var result = log.setLevel(log.levels.WARN);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("with a console that only supports console.log", function() {
|
||||
beforeEach(function() {
|
||||
window.console = mockConsole();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
it("log can be set to silent", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it("log can be set to an active level", function() {
|
||||
log.setLevel(log.levels.ERROR);
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
consoleLogIsCalledBy(log, "trace");
|
||||
consoleLogIsCalledBy(log, "debug");
|
||||
consoleLogIsCalledBy(log, "info");
|
||||
consoleLogIsCalledBy(log, "warn");
|
||||
consoleLogIsCalledBy(log, "trace");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
122
ExACTRegressionScripts/node_modules/loglevel/test/cookie-test.js
generated
vendored
Normal file
122
ExACTRegressionScripts/node_modules/loglevel/test/cookie-test.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
var originalConsole = window.console;
|
||||
var originalDocument = window.document;
|
||||
|
||||
describeIf(testHelpers.isCookieStorageAvailable() && !testHelpers.isLocalStorageAvailable(),
|
||||
"Cookie-only persistence tests:", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel,
|
||||
"toBeTheStoredLevel" : testHelpers.toBeTheLevelStoredByCookie
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
describe("If no level is saved", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
it("log level is set to warn by default", function(log) {
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("warn is persisted as the current level", function(log) {
|
||||
expect("warn").toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log can be set to info level", function(log) {
|
||||
log.setLevel("info");
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log.setLevel() sets a cookie with the given level", function(log) {
|
||||
log.setLevel("debug");
|
||||
expect("debug").toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("If info level is saved", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setStoredLevel("info");
|
||||
});
|
||||
|
||||
it("info is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log can be changed to warn level", function(log) {
|
||||
log.setLevel("warn");
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("log.setLevel() overwrites the saved level", function(log) {
|
||||
log.setLevel("error");
|
||||
|
||||
expect("error").toBeTheStoredLevel();
|
||||
expect("info").not.toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("If the level is saved with other data", function() {
|
||||
beforeEach(function() {
|
||||
window.document.cookie = "qwe=asd";
|
||||
window.document.cookie = "loglevel=ERROR";
|
||||
window.document.cookie = "msg=hello world";
|
||||
});
|
||||
|
||||
it("error is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("error");
|
||||
});
|
||||
|
||||
it("log can be changed to silent level", function(log) {
|
||||
log.setLevel("silent");
|
||||
expect(log).toBeAtLevel("silent");
|
||||
});
|
||||
|
||||
it("log.setLevel() overrides the saved level only", function(log) {
|
||||
log.setLevel("debug");
|
||||
|
||||
expect('debug').toBeTheStoredLevel();
|
||||
expect(window.document.cookie).toContain("msg=hello world");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If the level cookie is set incorrectly", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setCookieStoredLevel('gibberish');
|
||||
});
|
||||
|
||||
it("warn is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("warn is persisted as the current level, overriding the invalid cookie", function(log) {
|
||||
expect("warn").toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log can be changed to info level", function(log) {
|
||||
log.setLevel("info");
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log.setLevel() overrides the saved level with the new level", function(log) {
|
||||
expect('debug').not.toBeTheStoredLevel();
|
||||
|
||||
log.setLevel("debug");
|
||||
|
||||
expect('debug').toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
81
ExACTRegressionScripts/node_modules/loglevel/test/default-level-test.js
generated
vendored
Normal file
81
ExACTRegressionScripts/node_modules/loglevel/test/default-level-test.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
var originalConsole = window.console;
|
||||
|
||||
describe("Setting default log level tests:", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel,
|
||||
"toBeTheStoredLevel" : testHelpers.toBeTheLevelStoredByLocalStorage
|
||||
});
|
||||
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
describe("If no level is saved", function() {
|
||||
beforeEach(function () {
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
it("new level is always set", function(log) {
|
||||
log.setDefaultLevel("trace");
|
||||
expect(log).toBeAtLevel("trace");
|
||||
});
|
||||
|
||||
it("level is not persisted", function(log) {
|
||||
log.setDefaultLevel("debug");
|
||||
expect("debug").not.toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("If a level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("trace");
|
||||
});
|
||||
|
||||
it("saved level is not modified", function (log) {
|
||||
log.setDefaultLevel("debug");
|
||||
expect(log).toBeAtLevel("trace");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If the level is stored incorrectly", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setLocalStorageStoredLevel("gibberish");
|
||||
});
|
||||
|
||||
it("new level is set", function(log) {
|
||||
log.setDefaultLevel("debug");
|
||||
expect(log).toBeAtLevel("debug");
|
||||
expect("debug").not.toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.resetLevel() resets the log", function() {
|
||||
it("to warn if no explicit default is set", function(log) {
|
||||
log.setLevel("debug");
|
||||
log.resetLevel();
|
||||
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("to info if default is set to info", function(log) {
|
||||
log.setDefaultLevel("info");
|
||||
log.setLevel("debug");
|
||||
log.resetLevel();
|
||||
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
52
ExACTRegressionScripts/node_modules/loglevel/test/get-current-level-test.js
generated
vendored
Normal file
52
ExACTRegressionScripts/node_modules/loglevel/test/get-current-level-test.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
var originalConsole = window.console;
|
||||
|
||||
describe("Setting default log level tests:", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
describe("If no level is saved", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
it("current level is the default level", function(log) {
|
||||
log.setDefaultLevel("trace");
|
||||
expect(log.getLevel()).toBe(log.levels.TRACE);
|
||||
});
|
||||
});
|
||||
|
||||
describe("If a level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("trace");
|
||||
});
|
||||
|
||||
it("current level is the level which has been saved", function (log) {
|
||||
log.setDefaultLevel("debug");
|
||||
expect(log.getLevel()).toBe(log.levels.TRACE);
|
||||
});
|
||||
});
|
||||
|
||||
describe("If the level is stored incorrectly", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setLocalStorageStoredLevel("gibberish");
|
||||
});
|
||||
|
||||
it("current level is the default level", function(log) {
|
||||
log.setDefaultLevel("debug");
|
||||
expect(log.getLevel()).toBe(log.levels.DEBUG);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
30
ExACTRegressionScripts/node_modules/loglevel/test/global-integration-with-new-context.js
generated
vendored
Normal file
30
ExACTRegressionScripts/node_modules/loglevel/test/global-integration-with-new-context.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/* global MyCustomLogger, log */
|
||||
"use strict";
|
||||
|
||||
describe("loglevel from a global <script> tag with a custom context", function () {
|
||||
it("is available globally", function () {
|
||||
expect(MyCustomLogger).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("doesn't have log defined globally", function () {
|
||||
expect(window.log).not.toBeDefined();
|
||||
});
|
||||
|
||||
it("allows setting the logging level", function () {
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.TRACE);
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.DEBUG);
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.WARN);
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.ERROR);
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it("successfully logs", function () {
|
||||
window.console = { "log": jasmine.createSpy("log") };
|
||||
|
||||
MyCustomLogger.setLevel(MyCustomLogger.levels.INFO);
|
||||
MyCustomLogger.info("test message");
|
||||
|
||||
expect(console.log).toHaveBeenCalledWith("test message");
|
||||
});
|
||||
});
|
||||
44
ExACTRegressionScripts/node_modules/loglevel/test/global-integration.js
generated
vendored
Normal file
44
ExACTRegressionScripts/node_modules/loglevel/test/global-integration.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* global log */
|
||||
"use strict";
|
||||
|
||||
describe("loglevel from a global <script> tag", function () {
|
||||
it("is available globally", function () {
|
||||
expect(log).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows setting the logging level", function () {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
log.setLevel(log.levels.INFO);
|
||||
log.setLevel(log.levels.WARN);
|
||||
log.setLevel(log.levels.ERROR);
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
it("successfully logs", function () {
|
||||
window.console = { "log": jasmine.createSpy("log") };
|
||||
|
||||
log.setLevel(log.levels.INFO);
|
||||
log.info("test message");
|
||||
|
||||
expect(console.log).toHaveBeenCalledWith("test message");
|
||||
});
|
||||
|
||||
describe("noConflict()", function () {
|
||||
var globalLog;
|
||||
|
||||
beforeEach(function () {
|
||||
globalLog = window.log;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
window.log = globalLog;
|
||||
});
|
||||
|
||||
it("removes global reference to `log`", function () {
|
||||
var local = log.noConflict();
|
||||
expect(window.log).toBeUndefined();
|
||||
expect(local).toEqual(globalLog);
|
||||
});
|
||||
});
|
||||
});
|
||||
71
ExACTRegressionScripts/node_modules/loglevel/test/integration-smoke-test.js
generated
vendored
Normal file
71
ExACTRegressionScripts/node_modules/loglevel/test/integration-smoke-test.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
define(['../lib/loglevel', 'test/test-helpers'], function(log, testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var itIf = testHelpers.itIf;
|
||||
|
||||
describe("Integration smoke tests:", function() {
|
||||
describe("log methods", function() {
|
||||
it("can all be disabled", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
log.trace("trace");
|
||||
log.debug("debug");
|
||||
log.log("log");
|
||||
log.info("info");
|
||||
log.warn("warn");
|
||||
log.error("error");
|
||||
expect().nothing();
|
||||
});
|
||||
});
|
||||
|
||||
describeIf(typeof console !== "undefined", "log methods", function() {
|
||||
it("can all be called", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log.trace("trace");
|
||||
log.debug("debug");
|
||||
log.log("log");
|
||||
log.info("info");
|
||||
log.warn("warn");
|
||||
log.error("error");
|
||||
expect().nothing();
|
||||
});
|
||||
});
|
||||
|
||||
describeIf(typeof console !== "undefined", "log levels", function() {
|
||||
beforeEach(function() {
|
||||
jasmine.addMatchers({
|
||||
"toBeTheStoredLevel" : testHelpers.toBeTheStoredLevel
|
||||
});
|
||||
});
|
||||
|
||||
it("are all settable", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
log.setLevel(log.levels.INFO);
|
||||
log.setLevel(log.levels.WARN);
|
||||
log.setLevel(log.levels.ERROR);
|
||||
expect().nothing();
|
||||
});
|
||||
|
||||
itIf(testHelpers.isAnyLevelStoragePossible(), "are persisted", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
expect('trace').toBeTheStoredLevel();
|
||||
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
expect('debug').toBeTheStoredLevel();
|
||||
|
||||
log.setLevel(log.levels.INFO);
|
||||
expect('info').toBeTheStoredLevel();
|
||||
|
||||
log.setLevel(log.levels.WARN);
|
||||
expect('warn').toBeTheStoredLevel();
|
||||
|
||||
log.setLevel(log.levels.ERROR);
|
||||
expect('error').toBeTheStoredLevel();
|
||||
|
||||
log.setLevel(log.levels.SILENT);
|
||||
expect('silent').toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
281
ExACTRegressionScripts/node_modules/loglevel/test/level-setting-test.js
generated
vendored
Normal file
281
ExACTRegressionScripts/node_modules/loglevel/test/level-setting-test.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
"use strict";
|
||||
|
||||
var logMethods = [
|
||||
"trace",
|
||||
"debug",
|
||||
"info",
|
||||
"warn",
|
||||
"error"
|
||||
];
|
||||
|
||||
function getConsoleMethod(logMethodName) {
|
||||
if (logMethodName === 'debug') {
|
||||
return console.log;
|
||||
} else {
|
||||
return console[logMethodName];
|
||||
}
|
||||
}
|
||||
|
||||
define(['../lib/loglevel'], function(log) {
|
||||
var originalConsole = window.console;
|
||||
|
||||
describe("Basic log levels changing tests:", function() {
|
||||
beforeEach(function() {
|
||||
window.console = {};
|
||||
|
||||
for (var ii = 0; ii < logMethods.length; ii++) {
|
||||
window.console[logMethods[ii]] = jasmine.createSpy(logMethods[ii]);
|
||||
}
|
||||
|
||||
window.console.log = jasmine.createSpy('log');
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
describe("log.enableAll()", function() {
|
||||
it("enables all log methods", function() {
|
||||
log.enableAll(false);
|
||||
|
||||
for (var ii = 0; ii < logMethods.length; ii++) {
|
||||
var method = logMethods[ii];
|
||||
log[method]("a log message");
|
||||
|
||||
expect(getConsoleMethod(method)).toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.disableAll()", function() {
|
||||
it("disables all log methods", function() {
|
||||
log.disableAll(false);
|
||||
|
||||
for (var ii = 0; ii < logMethods.length; ii++) {
|
||||
var method = logMethods[ii];
|
||||
log[method]("a log message");
|
||||
|
||||
expect(getConsoleMethod(method)).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.setLevel() throws errors if given", function() {
|
||||
it("no level argument", function() {
|
||||
expect(function() {
|
||||
log.setLevel();
|
||||
}).toThrowError(TypeError, "log.setLevel() called with invalid level: undefined");
|
||||
});
|
||||
|
||||
it("a null level argument", function() {
|
||||
expect(function() {
|
||||
log.setLevel(null);
|
||||
}).toThrowError(TypeError, "log.setLevel() called with invalid level: null");
|
||||
});
|
||||
|
||||
it("an undefined level argument", function() {
|
||||
expect(function() {
|
||||
log.setLevel(undefined);
|
||||
}).toThrowError(TypeError, "log.setLevel() called with invalid level: undefined");
|
||||
});
|
||||
|
||||
it("an invalid log level index", function() {
|
||||
expect(function() {
|
||||
log.setLevel(-1);
|
||||
}).toThrowError(TypeError, "log.setLevel() called with invalid level: -1");
|
||||
});
|
||||
|
||||
it("an invalid log level name", function() {
|
||||
expect(function() {
|
||||
log.setLevel("InvalidLevelName");
|
||||
}).toThrowError(TypeError, "log.setLevel() called with invalid level: InvalidLevelName");
|
||||
});
|
||||
});
|
||||
|
||||
describe("setting log level by name", function() {
|
||||
function itCanSetLogLevelTo(level) {
|
||||
it("can set log level to " + level, function() {
|
||||
log.setLevel(level, false);
|
||||
|
||||
log[level]("log message");
|
||||
expect(getConsoleMethod(level)).toHaveBeenCalled();
|
||||
});
|
||||
}
|
||||
|
||||
itCanSetLogLevelTo("trace");
|
||||
itCanSetLogLevelTo("debug");
|
||||
itCanSetLogLevelTo("info");
|
||||
itCanSetLogLevelTo("warn");
|
||||
itCanSetLogLevelTo("error");
|
||||
});
|
||||
|
||||
describe("log level settings", function() {
|
||||
describe("log.trace", function() {
|
||||
it("is enabled at trace level", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
|
||||
log.trace("a log message");
|
||||
expect(console.trace).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at debug level", function() {
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
|
||||
log.trace("a log message");
|
||||
expect(console.trace).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.trace("a log message");
|
||||
expect(console.trace).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.debug", function() {
|
||||
it("is enabled at trace level", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
|
||||
log.debug("a log message");
|
||||
expect(console.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is enabled at debug level", function() {
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
|
||||
log.debug("a log message");
|
||||
expect(console.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at info level", function() {
|
||||
log.setLevel(log.levels.INFO);
|
||||
|
||||
log.debug("a log message");
|
||||
expect(console.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.debug("a log message");
|
||||
expect(console.log).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.log", function() {
|
||||
it("is enabled at trace level", function() {
|
||||
log.setLevel(log.levels.TRACE);
|
||||
|
||||
log.log("a log message");
|
||||
expect(console.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is enabled at debug level", function() {
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
|
||||
log.log("a log message");
|
||||
expect(console.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at info level", function() {
|
||||
log.setLevel(log.levels.INFO);
|
||||
|
||||
log.log("a log message");
|
||||
expect(console.log).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.log("a log message");
|
||||
expect(console.log).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.info", function() {
|
||||
it("is enabled at debug level", function() {
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
|
||||
log.info("a log message");
|
||||
expect(console.info).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is enabled at info level", function() {
|
||||
log.setLevel(log.levels.INFO);
|
||||
|
||||
log.info("a log message");
|
||||
expect(console.info).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at warn level", function() {
|
||||
log.setLevel(log.levels.WARN);
|
||||
|
||||
log.info("a log message");
|
||||
expect(console.info).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.info("a log message");
|
||||
expect(console.info).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.warn", function() {
|
||||
it("is enabled at info level", function() {
|
||||
log.setLevel(log.levels.INFO);
|
||||
|
||||
log.warn("a log message");
|
||||
expect(console.warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is enabled at warn level", function() {
|
||||
log.setLevel(log.levels.WARN);
|
||||
|
||||
log.warn("a log message");
|
||||
expect(console.warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at error level", function() {
|
||||
log.setLevel(log.levels.ERROR);
|
||||
|
||||
log.warn("a log message");
|
||||
expect(console.warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.warn("a log message");
|
||||
expect(console.warn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("log.error", function() {
|
||||
it("is enabled at warn level", function() {
|
||||
log.setLevel(log.levels.WARN);
|
||||
|
||||
log.error("a log message");
|
||||
expect(console.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is enabled at error level", function() {
|
||||
log.setLevel(log.levels.ERROR);
|
||||
|
||||
log.error("a log message");
|
||||
expect(console.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("is disabled at silent level", function() {
|
||||
log.setLevel(log.levels.SILENT);
|
||||
|
||||
log.error("a log message");
|
||||
expect(console.error).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
210
ExACTRegressionScripts/node_modules/loglevel/test/local-storage-test.js
generated
vendored
Normal file
210
ExACTRegressionScripts/node_modules/loglevel/test/local-storage-test.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
var originalConsole = window.console;
|
||||
|
||||
describeIf(testHelpers.isLocalStorageAvailable(), "Local storage persistence tests:", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel,
|
||||
"toBeTheStoredLevel" : testHelpers.toBeTheLevelStoredByLocalStorage,
|
||||
"toBeTheLevelStoredByLocalStorage": testHelpers.toBeTheLevelStoredByLocalStorage,
|
||||
"toBeTheLevelStoredByCookie": testHelpers.toBeTheLevelStoredByCookie
|
||||
});
|
||||
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
describe("If no level is saved", function() {
|
||||
it("log level is set to warn by default", function(log) {
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("warn is not persisted as the current level", function(log) {
|
||||
expect("warn").not.toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log can be set to info level", function(log) {
|
||||
log.setLevel("info");
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log.setLevel() sets a cookie with the given level", function(log) {
|
||||
log.setLevel("debug");
|
||||
expect("debug").toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log.setLevel() does not set a cookie if `persist` argument is false", function(log) {
|
||||
log.setLevel("debug", false);
|
||||
expect("debug").not.toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("If trace level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("trace");
|
||||
});
|
||||
|
||||
it("trace is the default log level", function (log) {
|
||||
expect(log).toBeAtLevel("trace");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If debug level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("debug");
|
||||
});
|
||||
|
||||
it("debug is the default log level", function (log) {
|
||||
expect(log).toBeAtLevel("debug");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If info level is saved", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setStoredLevel("info");
|
||||
});
|
||||
|
||||
it("info is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log can be changed to warn level", function(log) {
|
||||
log.setLevel("warn");
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("log.setLevel() overwrites the saved level", function(log) {
|
||||
log.setLevel("error");
|
||||
|
||||
expect("error").toBeTheStoredLevel();
|
||||
expect("info").not.toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log.setLevel() does not overwrite the saved level if `persist` argument is false", function(log) {
|
||||
log.setLevel("error", false);
|
||||
|
||||
expect("info").toBeTheStoredLevel();
|
||||
expect("error").not.toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log.resetLevel() clears the saved level", function(log) {
|
||||
log.resetLevel();
|
||||
|
||||
expect(undefined).toBeTheStoredLevel();
|
||||
expect("info").not.toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describe("If warn level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("warn");
|
||||
});
|
||||
|
||||
it("warn is the default log level", function (log) {
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If error level is saved", function () {
|
||||
beforeEach(function () {
|
||||
testHelpers.setStoredLevel("error");
|
||||
});
|
||||
|
||||
it("error is the default log level", function (log) {
|
||||
expect(log).toBeAtLevel("error");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("If the level is saved with other data", function() {
|
||||
beforeEach(function() {
|
||||
window.localStorage['qwe'] = "asd";
|
||||
window.localStorage['loglevel'] = "ERROR";
|
||||
window.localStorage['msg'] = "hello world";
|
||||
});
|
||||
|
||||
it("error is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("error");
|
||||
});
|
||||
|
||||
it("log can be changed to silent level", function(log) {
|
||||
log.setLevel("silent");
|
||||
expect(log).toBeAtLevel("silent");
|
||||
});
|
||||
|
||||
it("log.setLevel() overrides the saved level only", function(log) {
|
||||
log.setLevel("debug");
|
||||
|
||||
expect('debug').toBeTheStoredLevel();
|
||||
expect(window.localStorage['msg']).toBe("hello world");
|
||||
});
|
||||
});
|
||||
|
||||
describe("If the level is stored incorrectly", function() {
|
||||
beforeEach(function() {
|
||||
testHelpers.setLocalStorageStoredLevel('gibberish');
|
||||
});
|
||||
|
||||
it("warn is the default log level", function(log) {
|
||||
expect(log).toBeAtLevel("warn");
|
||||
});
|
||||
|
||||
it("warn is not persisted as the current level", function(log) {
|
||||
expect("warn").not.toBeTheStoredLevel();
|
||||
});
|
||||
|
||||
it("log can be changed to info level", function(log) {
|
||||
log.setLevel("info");
|
||||
expect(log).toBeAtLevel("info");
|
||||
});
|
||||
|
||||
it("log.setLevel() overrides the saved level with the new level", function(log) {
|
||||
expect('debug').not.toBeTheStoredLevel();
|
||||
|
||||
log.setLevel("debug");
|
||||
|
||||
expect('debug').toBeTheStoredLevel();
|
||||
});
|
||||
});
|
||||
|
||||
describeIf(testHelpers.isCookieStorageAvailable() && testHelpers.isLocalStorageAvailable(),
|
||||
"if localStorage and cookies are both available", function () {
|
||||
|
||||
it("the level stored in cookies is ignored if a local storage level is set", function (log, done) {
|
||||
testHelpers.setCookieStoredLevel("info");
|
||||
testHelpers.setLocalStorageStoredLevel("debug");
|
||||
|
||||
testHelpers.withFreshLog(function (log) {
|
||||
expect(log).toBeAtLevel("debug");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("the level stored in cookies is used if no local storage level is set", function (log, done) {
|
||||
testHelpers.setCookieStoredLevel("info");
|
||||
window.localStorage.clear();
|
||||
|
||||
testHelpers.withFreshLog(function (log) {
|
||||
expect(log).toBeAtLevel("info");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("the local storage level is set and the cookie level is not", function (log) {
|
||||
log.setLevel("error");
|
||||
expect("error").toBeTheLevelStoredByLocalStorage();
|
||||
expect("error").not.toBeTheLevelStoredByCookie();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
8
ExACTRegressionScripts/node_modules/loglevel/test/manual-test.html
generated
vendored
Normal file
8
ExACTRegressionScripts/node_modules/loglevel/test/manual-test.html
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Standalone manual test bed for loglevel</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../lib/loglevel.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
42
ExACTRegressionScripts/node_modules/loglevel/test/method-factory-test.js
generated
vendored
Normal file
42
ExACTRegressionScripts/node_modules/loglevel/test/method-factory-test.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
describe("Setting the methodFactory tests:", function() {
|
||||
|
||||
it("methodFactory should be called once for each loggable level", function(log) {
|
||||
log.methodFactory = jasmine.createSpy("methodFactory");
|
||||
|
||||
log.setLevel("trace");
|
||||
expect(log.methodFactory.calls.count()).toEqual(5);
|
||||
expect(log.methodFactory.calls.argsFor(0)).toEqual(["trace", 0, undefined]);
|
||||
expect(log.methodFactory.calls.argsFor(1)).toEqual(["debug", 0, undefined]);
|
||||
expect(log.methodFactory.calls.argsFor(2)).toEqual(["info", 0, undefined]);
|
||||
expect(log.methodFactory.calls.argsFor(3)).toEqual(["warn", 0, undefined]);
|
||||
expect(log.methodFactory.calls.argsFor(4)).toEqual(["error", 0, undefined]);
|
||||
|
||||
log.setLevel("error");
|
||||
expect(log.methodFactory.calls.count()).toEqual(6);
|
||||
expect(log.methodFactory.calls.argsFor(5)).toEqual(["error", 4, undefined]);
|
||||
});
|
||||
|
||||
it("functions returned by methodFactory should be used as logging functions", function(log) {
|
||||
var logFunction = function() {};
|
||||
log.methodFactory = function() { return logFunction; };
|
||||
log.setLevel("error");
|
||||
|
||||
expect(log.warn).not.toEqual(logFunction);
|
||||
expect(log.error).toEqual(logFunction);
|
||||
});
|
||||
|
||||
it("the third argument should be logger's name", function(log) {
|
||||
var logger = log.getLogger("newLogger");
|
||||
logger.methodFactory = jasmine.createSpy("methodFactory");
|
||||
|
||||
logger.setLevel("error");
|
||||
expect(logger.methodFactory.calls.argsFor(0)).toEqual(["error", 4, "newLogger"]);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
275
ExACTRegressionScripts/node_modules/loglevel/test/multiple-logger-test.js
generated
vendored
Normal file
275
ExACTRegressionScripts/node_modules/loglevel/test/multiple-logger-test.js
generated
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
"use strict";
|
||||
|
||||
define(['test/test-helpers'], function(testHelpers) {
|
||||
var describeIf = testHelpers.describeIf;
|
||||
var it = testHelpers.itWithFreshLog;
|
||||
|
||||
var originalConsole = window.console;
|
||||
|
||||
describe("Multiple logger instances tests:", function() {
|
||||
|
||||
describe("log.getLogger()", function() {
|
||||
it("returns a new logger that is not the default one", function(log) {
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).not.toEqual(log);
|
||||
expect(newLogger.trace).toBeDefined();
|
||||
expect(newLogger.debug).toBeDefined();
|
||||
expect(newLogger.info).toBeDefined();
|
||||
expect(newLogger.warn).toBeDefined();
|
||||
expect(newLogger.error).toBeDefined();
|
||||
expect(newLogger.setLevel).toBeDefined();
|
||||
expect(newLogger.setDefaultLevel).toBeDefined();
|
||||
expect(newLogger.enableAll).toBeDefined();
|
||||
expect(newLogger.disableAll).toBeDefined();
|
||||
expect(newLogger.methodFactory).toBeDefined();
|
||||
});
|
||||
|
||||
it("returns loggers without `getLogger()` and `noConflict()`", function(log) {
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger.getLogger).toBeUndefined();
|
||||
expect(newLogger.noConflict).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns the same instance when called repeatedly with the same name", function(log) {
|
||||
var logger1 = log.getLogger("newLogger");
|
||||
var logger2 = log.getLogger("newLogger");
|
||||
|
||||
expect(logger1).toEqual(logger2);
|
||||
});
|
||||
|
||||
it("should throw if called with no name", function(log) {
|
||||
expect(function() {
|
||||
log.getLogger();
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it("should throw if called with empty string for name", function(log) {
|
||||
expect(function() {
|
||||
log.getLogger("");
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it("should throw if called with a non-string name", function(log) {
|
||||
expect(function() { log.getLogger(true); }).toThrow();
|
||||
expect(function() { log.getLogger({}); }).toThrow();
|
||||
expect(function() { log.getLogger([]); }).toThrow();
|
||||
expect(function() { log.getLogger(10); }).toThrow();
|
||||
expect(function() { log.getLogger(function(){}); }).toThrow();
|
||||
expect(function() { log.getLogger(null); }).toThrow();
|
||||
expect(function() { log.getLogger(undefined); }).toThrow();
|
||||
});
|
||||
|
||||
// NOTE: this test is the same as the similarly-named test in
|
||||
// `node-integration.js` (which only runs in Node.js). If making
|
||||
// changes here, be sure to adjust that test as well.
|
||||
it(typeof Symbol !== "undefined", "supports using symbols as names", function(log) {
|
||||
var s1 = Symbol("a-symbol");
|
||||
var s2 = Symbol("a-symbol");
|
||||
|
||||
var logger1 = log.getLogger(s1);
|
||||
var defaultLevel = logger1.getLevel();
|
||||
logger1.setLevel(log.levels.TRACE);
|
||||
|
||||
var logger2 = log.getLogger(s2);
|
||||
|
||||
// Should be unequal: same name, but different symbol instances
|
||||
expect(logger1).not.toEqual(logger2);
|
||||
expect(logger2.getLevel()).toEqual(defaultLevel);
|
||||
});
|
||||
});
|
||||
|
||||
describe("inheritance", function() {
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel
|
||||
});
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
it("loggers are created with the same level as the default logger", function(log) {
|
||||
log.setLevel("ERROR");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("error");
|
||||
});
|
||||
|
||||
it("if a logger's level is persisted, it uses that level rather than the default logger's level", function(log) {
|
||||
testHelpers.setStoredLevel("error", "newLogger");
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("error");
|
||||
});
|
||||
|
||||
it("other loggers do not change when the default logger's level is changed", function(log) {
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
log.setLevel("ERROR");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
expect(log.getLogger("newLogger")).toBeAtLevel("TRACE");
|
||||
});
|
||||
|
||||
it("loggers are created with the same methodFactory as the default logger", function(log) {
|
||||
log.methodFactory = function(methodName, level) {
|
||||
return function() {};
|
||||
};
|
||||
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger.methodFactory).toEqual(log.methodFactory);
|
||||
});
|
||||
|
||||
it("loggers have independent method factories", function(log) {
|
||||
var log1 = log.getLogger('logger1');
|
||||
var log2 = log.getLogger('logger2');
|
||||
|
||||
var log1Spy = jasmine.createSpy('log1spy');
|
||||
log1.methodFactory = function(methodName, level) {
|
||||
return log1Spy;
|
||||
};
|
||||
log1.setLevel(log1.getLevel());
|
||||
|
||||
var log2Spy = jasmine.createSpy('log2spy');
|
||||
log2.methodFactory = function(methodName, level) {
|
||||
return log2Spy;
|
||||
};
|
||||
log2.setLevel(log2.getLevel());
|
||||
|
||||
log1.error('test1');
|
||||
log2.error('test2');
|
||||
|
||||
expect(log1Spy).toHaveBeenCalledWith("test1");
|
||||
expect(log2Spy).toHaveBeenCalledWith("test2");
|
||||
});
|
||||
|
||||
it("new loggers correctly inherit a logging level of `0`", function(log) {
|
||||
log.setLevel(0);
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("trace");
|
||||
});
|
||||
});
|
||||
|
||||
describe("logger.resetLevel()", function() {
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel
|
||||
});
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
it("resets to the inherited level if no local level was set", function(log) {
|
||||
testHelpers.setStoredLevel("ERROR", "newLogger");
|
||||
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
|
||||
newLogger.resetLevel();
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
// resetLevel() should not have broken inheritance.
|
||||
log.setLevel("DEBUG");
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("DEBUG");
|
||||
});
|
||||
|
||||
it("resets to the inherited level if no default level was set", function(log) {
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
newLogger.setLevel("ERROR");
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
|
||||
newLogger.resetLevel();
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
// resetLevel() should not have broken inheritance.
|
||||
log.setLevel("DEBUG");
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("DEBUG");
|
||||
});
|
||||
|
||||
it("resets to the default level if one was set", function(log) {
|
||||
testHelpers.setStoredLevel("ERROR", "newLogger");
|
||||
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
newLogger.setDefaultLevel("INFO");
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
|
||||
newLogger.resetLevel();
|
||||
expect(newLogger).toBeAtLevel("INFO");
|
||||
|
||||
// resetLevel() should not have caused inheritance to start.
|
||||
log.setLevel("DEBUG");
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("INFO");
|
||||
});
|
||||
});
|
||||
|
||||
describe("logger.rebuild()", function() {
|
||||
beforeEach(function() {
|
||||
window.console = {"log" : jasmine.createSpy("console.log")};
|
||||
jasmine.addMatchers({
|
||||
"toBeAtLevel" : testHelpers.toBeAtLevel
|
||||
});
|
||||
testHelpers.clearStoredLevels();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
window.console = originalConsole;
|
||||
});
|
||||
|
||||
it("rebuilds existing child loggers", function(log) {
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
log.setLevel("ERROR");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
});
|
||||
|
||||
it("should not change a child's persisted level", function(log) {
|
||||
testHelpers.setStoredLevel("ERROR", "newLogger");
|
||||
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("ERROR");
|
||||
});
|
||||
|
||||
it("should not change a child's level set with `setLevel()`", function(log) {
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
newLogger.setLevel("DEBUG", false);
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("DEBUG");
|
||||
});
|
||||
|
||||
it("should not change a child's level set with `setDefaultLevel()`", function(log) {
|
||||
log.setLevel("TRACE");
|
||||
var newLogger = log.getLogger("newLogger");
|
||||
expect(newLogger).toBeAtLevel("TRACE");
|
||||
|
||||
newLogger.setDefaultLevel("DEBUG");
|
||||
log.rebuild();
|
||||
expect(newLogger).toBeAtLevel("DEBUG");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
47
ExACTRegressionScripts/node_modules/loglevel/test/node-integration.js
generated
vendored
Normal file
47
ExACTRegressionScripts/node_modules/loglevel/test/node-integration.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
describe("loglevel included via node", function () {
|
||||
it("is included successfully", function () {
|
||||
expect(require('../lib/loglevel')).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows setting the logging level", function () {
|
||||
var log = require('../lib/loglevel');
|
||||
|
||||
log.setLevel(log.levels.TRACE);
|
||||
log.setLevel(log.levels.DEBUG);
|
||||
log.setLevel(log.levels.INFO);
|
||||
log.setLevel(log.levels.WARN);
|
||||
log.setLevel(log.levels.ERROR);
|
||||
});
|
||||
|
||||
it("successfully logs", function () {
|
||||
var log = require('../lib/loglevel');
|
||||
console.info = jasmine.createSpy("info");
|
||||
|
||||
log.setLevel(log.levels.INFO);
|
||||
log.info("test message");
|
||||
|
||||
expect(console.info).toHaveBeenCalledWith("test message");
|
||||
});
|
||||
|
||||
// NOTE: this test is the same as the similarly-named test in
|
||||
// `multiple-logger-test.js` (which only runs in browsers). If making
|
||||
// changes here, be sure to adjust that test as well.
|
||||
it("supports using symbols as names", function() {
|
||||
var log = require('../lib/loglevel');
|
||||
|
||||
var s1 = Symbol("a-symbol");
|
||||
var s2 = Symbol("a-symbol");
|
||||
|
||||
var logger1 = log.getLogger(s1);
|
||||
var defaultLevel = logger1.getLevel();
|
||||
logger1.setLevel(log.levels.TRACE);
|
||||
|
||||
var logger2 = log.getLogger(s2);
|
||||
|
||||
// Should be unequal: same name, but different symbol instances
|
||||
expect(logger1).not.toEqual(logger2);
|
||||
expect(logger2.getLevel()).toEqual(defaultLevel);
|
||||
});
|
||||
});
|
||||
6
ExACTRegressionScripts/node_modules/loglevel/test/test-context-using-apply.js
generated
vendored
Normal file
6
ExACTRegressionScripts/node_modules/loglevel/test/test-context-using-apply.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
/* jshint node:true */
|
||||
var MyCustomLogger = (function() {
|
||||
// @include ../lib/loglevel.js
|
||||
return this.log;
|
||||
}).apply({});
|
||||
237
ExACTRegressionScripts/node_modules/loglevel/test/test-helpers.js
generated
vendored
Normal file
237
ExACTRegressionScripts/node_modules/loglevel/test/test-helpers.js
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
"use strict";
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
window = {};
|
||||
}
|
||||
|
||||
var logMethods = [
|
||||
"trace",
|
||||
"debug",
|
||||
"info",
|
||||
"warn",
|
||||
"error"
|
||||
];
|
||||
|
||||
define(function () {
|
||||
function getStorageKey(loggerName) {
|
||||
var key = "loglevel";
|
||||
if (loggerName) {
|
||||
key += ":" + loggerName;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
var self = {};
|
||||
|
||||
// Jasmine matcher to check the log level of a log object. Usage:
|
||||
// expect(log).toBeAtLevel("DEBUG");
|
||||
self.toBeAtLevel = function toBeAtLevel() {
|
||||
return {
|
||||
compare: function (log, level) {
|
||||
var expectedWorkingCalls = log.levels.SILENT - log.levels[level.toUpperCase()];
|
||||
var realLogMethod = window.console.log;
|
||||
var priorCalls = realLogMethod.calls.count();
|
||||
|
||||
for (var ii = 0; ii < logMethods.length; ii++) {
|
||||
var methodName = logMethods[ii];
|
||||
log[methodName](methodName);
|
||||
}
|
||||
|
||||
var actualCalls = realLogMethod.calls.count() - priorCalls;
|
||||
var actualLevel = logMethods[log.levels.SILENT - actualCalls];
|
||||
return {
|
||||
pass: actualCalls === expectedWorkingCalls,
|
||||
message: "Expected level to be '" + level + "' but found '" + actualLevel + "'"
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
self.isCookieStorageAvailable = function isCookieStorageAvailable() {
|
||||
if (window && window.document && window.document.cookie != null) {
|
||||
// We need to check not just that the cookie objects are available, but that they work, because
|
||||
// if we run from file:// URLs they appear present but are non-functional
|
||||
window.document.cookie = "test=hi;";
|
||||
|
||||
var result = window.document.cookie.indexOf('test=hi') !== -1;
|
||||
window.document.cookie = "test=; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
||||
|
||||
return result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
self.isLocalStorageAvailable = function isLocalStorageAvailable() {
|
||||
try {
|
||||
return !!window.localStorage;
|
||||
} catch (e){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
self.isAnyLevelStoragePossible = function isAnyLevelStoragePossible() {
|
||||
return self.isCookieStorageAvailable() || self.isLocalStorageAvailable();
|
||||
};
|
||||
|
||||
// Check whether a cookie is storing the given level for the given logger
|
||||
// name. If level is `undefined`, this will check that it is *not* stored.
|
||||
function isLevelInCookie(level, name) {
|
||||
level = level === undefined ? undefined : level.toUpperCase();
|
||||
var storageKey = encodeURIComponent(getStorageKey(name));
|
||||
|
||||
if(level === undefined) {
|
||||
return window.document.cookie.indexOf(storageKey + "=") === -1;
|
||||
} else if (window.document.cookie.indexOf(storageKey + "=" + level) !== -1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Jasmine matcher to check whether the given log level is in a cookie.
|
||||
// Usage: `expect("DEBUG").toBeTheLevelStoredByCookie("name-of-logger")`
|
||||
self.toBeTheLevelStoredByCookie = function toBeTheLevelStoredByCookie() {
|
||||
return {
|
||||
compare: function (actual, name) {
|
||||
return {
|
||||
pass: isLevelInCookie(actual, name),
|
||||
message: "Level '" + actual + "' for the " + (name || "default") + " logger is not stored in a cookie"
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Check whether local storage is storing the given level for the given
|
||||
// logger name. If level is `undefined`, this will check that it is *not*
|
||||
// stored.
|
||||
function isLevelInLocalStorage(level, name) {
|
||||
level = level === undefined ? undefined : level.toUpperCase();
|
||||
|
||||
if (window.localStorage[getStorageKey(name)] === level) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Jasmine matcher to check whether the given log level is in local storage.
|
||||
// Usage: `expect("DEBUG").toBeTheLevelStoredByLocalStorage("name-of-logger")`
|
||||
self.toBeTheLevelStoredByLocalStorage = function toBeTheLevelStoredByLocalStorage() {
|
||||
return {
|
||||
compare: function (actual, name) {
|
||||
return {
|
||||
pass: isLevelInLocalStorage(actual, name),
|
||||
message: "Level '" + actual + "' for the " + (name || "default") + " logger is not stored in local storage"
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Jasmine matcher to check whether a given level has been persisted.
|
||||
self.toBeTheStoredLevel = function toBeTheStoredLevel() {
|
||||
return {
|
||||
compare: function (actual, name) {
|
||||
return {
|
||||
pass: isLevelInLocalStorage(actual, name) ||
|
||||
isLevelInCookie(actual, name),
|
||||
message: "Level '" + actual + "' is not persisted for the " + (name || "default") + " logger"
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
self.setCookieStoredLevel = function setCookieStoredLevel(level, name) {
|
||||
window.document.cookie =
|
||||
encodeURIComponent(getStorageKey(name)) + "=" +
|
||||
level.toUpperCase() + ";";
|
||||
};
|
||||
|
||||
self.setLocalStorageStoredLevel = function setLocalStorageStoredLevel(level, name) {
|
||||
window.localStorage[getStorageKey(name)] = level.toUpperCase();
|
||||
};
|
||||
|
||||
self.setStoredLevel = function setStoredLevel(level, name) {
|
||||
if (self.isCookieStorageAvailable()) {
|
||||
self.setCookieStoredLevel(level, name);
|
||||
}
|
||||
if (self.isLocalStorageAvailable()) {
|
||||
self.setLocalStorageStoredLevel(level, name);
|
||||
}
|
||||
};
|
||||
|
||||
self.clearStoredLevels = function clearStoredLevels() {
|
||||
if (self.isLocalStorageAvailable()) {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
if (self.isCookieStorageAvailable()) {
|
||||
var storedKeys = window.document.cookie.match(/(?:^|;\s)(loglevel(%3a\w+)?)(?=\=)/ig);
|
||||
if (storedKeys) {
|
||||
for (var i = 0; i < storedKeys.length; i++) {
|
||||
window.document.cookie = storedKeys[i] + "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.describeIf = function describeIf(condition, name, test) {
|
||||
var env = jasmine.getEnv();
|
||||
var implementation = condition ? env.describe : env.xdescribe;
|
||||
return implementation(name, test);
|
||||
};
|
||||
|
||||
self.itIf = function itIf(condition, name, test) {
|
||||
var env = jasmine.getEnv();
|
||||
var implementation = condition ? env.it : env.xit;
|
||||
return implementation(name, test);
|
||||
};
|
||||
|
||||
// Forcibly reloads loglevel and asynchronously hands the resulting log to
|
||||
// a callback.
|
||||
self.withFreshLog = function withFreshLog(toRun, onError) {
|
||||
require.undef("lib/loglevel");
|
||||
|
||||
require(['lib/loglevel'], function(log) {
|
||||
toRun(log);
|
||||
});
|
||||
};
|
||||
|
||||
// Wraps Jasmine's `it(name, test)` call to reload the loglevel module
|
||||
// for the given test. An optional boolean first argument causes this to
|
||||
// behave like `itIf()` instead of `it()`.
|
||||
//
|
||||
// Normal usage:
|
||||
// itWithFreshLog("test name", function(log) {
|
||||
// // test code
|
||||
// });
|
||||
//
|
||||
// Conditional usage:
|
||||
// itWithFreshLog(shouldRunTest(), "test name", function(log) {
|
||||
// // test code
|
||||
// });
|
||||
self.itWithFreshLog = function itWithFreshLog(condition, name, test) {
|
||||
if (!test) {
|
||||
test = name;
|
||||
name = condition;
|
||||
condition = true;
|
||||
}
|
||||
|
||||
self.itIf(condition, name, function(done) {
|
||||
function runTest (log) {
|
||||
if (test.length > 1) {
|
||||
return test(log, done);
|
||||
} else {
|
||||
try {
|
||||
test(log);
|
||||
done();
|
||||
} catch (error) {
|
||||
done.fail(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.withFreshLog(runTest);
|
||||
});
|
||||
};
|
||||
|
||||
return self;
|
||||
});
|
||||
8
ExACTRegressionScripts/node_modules/loglevel/test/type-test.ts
generated
vendored
Normal file
8
ExACTRegressionScripts/node_modules/loglevel/test/type-test.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as log from '..';
|
||||
|
||||
log.setLevel('warn');
|
||||
log.warn('Test warning');
|
||||
|
||||
// CoreJS defines a global `log` variable. We need to make sure that
|
||||
// that doesn't conflict with the loglevel typings:
|
||||
import * as _coreJS from 'core-js';
|
||||
Reference in New Issue
Block a user