2014-02-28 06:52:25 +08:00
|
|
|
'use strict';
|
2014-05-25 01:34:19 +08:00
|
|
|
|
2014-06-06 03:11:37 +08:00
|
|
|
var Logger = source('logger'),
|
|
|
|
Utils = source('utils');
|
2013-10-25 05:25:42 +08:00
|
|
|
|
2014-02-28 06:52:25 +08:00
|
|
|
describe('Logger', function() {
|
2014-03-22 07:15:13 +08:00
|
|
|
after(function() {
|
|
|
|
Logger.setup(false); // to be friendly to other specs
|
2013-10-25 05:25:42 +08:00
|
|
|
});
|
|
|
|
|
2014-03-22 07:15:13 +08:00
|
|
|
describe("#setup", function() {
|
|
|
|
context("with no arguments", function() {
|
|
|
|
it("sets up a BasicLogger", function() {
|
|
|
|
Logger.setup();
|
|
|
|
expect(Logger.toString()).to.be.eql("BasicLogger");
|
|
|
|
});
|
|
|
|
});
|
2014-02-28 06:52:25 +08:00
|
|
|
|
2014-03-22 07:15:13 +08:00
|
|
|
context("with false", function() {
|
|
|
|
it("sets up a NullLogger", function() {
|
|
|
|
Logger.setup(false);
|
|
|
|
expect(Logger.toString()).to.be.eql("NullLogger");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
context("with a custom logger", function() {
|
|
|
|
it("uses the custom logger", function() {
|
|
|
|
var logger = { toString: function() { return "custom"; } };
|
|
|
|
Logger.setup(logger);
|
|
|
|
expect(Logger.toString()).to.be.eql("custom");
|
|
|
|
});
|
|
|
|
});
|
2014-02-28 06:52:25 +08:00
|
|
|
});
|
|
|
|
|
2014-03-22 07:15:13 +08:00
|
|
|
describe("proxies", function() {
|
|
|
|
var logger = {
|
|
|
|
debug: spy(),
|
|
|
|
info: spy(),
|
|
|
|
warn: spy(),
|
|
|
|
error: spy(),
|
|
|
|
fatal: spy()
|
2014-02-28 06:52:25 +08:00
|
|
|
};
|
2014-03-22 07:15:13 +08:00
|
|
|
|
|
|
|
before(function() {
|
|
|
|
Logger.setup(logger);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#debug", function() {
|
|
|
|
it("proxies to the Logger's #debug method", function() {
|
|
|
|
Logger.debug("Hello", "World");
|
|
|
|
expect(logger.debug).to.be.calledWith("Hello", "World");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#info", function() {
|
|
|
|
it("proxies to the Logger's #info method", function() {
|
|
|
|
Logger.info("Hello", "World");
|
|
|
|
expect(logger.info).to.be.calledWith("Hello", "World");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#warn", function() {
|
|
|
|
it("proxies to the Logger's #warn method", function() {
|
|
|
|
Logger.warn("Hello", "World");
|
|
|
|
expect(logger.warn).to.be.calledWith("Hello", "World");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#error", function() {
|
|
|
|
it("proxies to the Logger's #error method", function() {
|
|
|
|
Logger.error("Hello", "World");
|
|
|
|
expect(logger.error).to.be.calledWith("Hello", "World");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#fatal", function() {
|
|
|
|
it("proxies to the Logger's #fatal method", function() {
|
|
|
|
Logger.fatal("Hello", "World");
|
|
|
|
expect(logger.fatal).to.be.calledWith("Hello", "World");
|
|
|
|
});
|
|
|
|
});
|
2014-02-28 06:52:25 +08:00
|
|
|
});
|
|
|
|
});
|