54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
"use strict";
|
|
var should = require('should')
|
|
, levels = require('../lib/levels')
|
|
, Logger = require('../lib/logger');
|
|
|
|
describe('../lib/logger', function() {
|
|
describe('Logger constructor', function() {
|
|
it('must be passed a dispatch delegate and a category', function() {
|
|
(function() { new Logger(); }).should.throw(
|
|
"Logger must have a dispatch delegate."
|
|
);
|
|
(function() { new Logger(function() {}); }).should.throw(
|
|
"Logger must have a category."
|
|
);
|
|
});
|
|
|
|
});
|
|
|
|
describe('Logger instance', function() {
|
|
var event
|
|
, logger = new Logger(
|
|
function(evt) { event = evt; },
|
|
"exciting category"
|
|
);
|
|
|
|
beforeEach(function() {
|
|
event = null;
|
|
});
|
|
|
|
it('should be immutable', function() {
|
|
logger.category = "rubbish";
|
|
logger.debug("thing");
|
|
|
|
event.category.should.equal("exciting category");
|
|
});
|
|
|
|
['trace', 'debug', 'info', 'warn', 'error', 'fatal'].forEach(function(level) {
|
|
it('should have a ' + level + ' function', function() {
|
|
logger[level].should.be.a('function');
|
|
});
|
|
});
|
|
|
|
it('should send log events to the dispatch delegate', function() {
|
|
logger.debug("interesting thing");
|
|
event.should.have.property('category').equal('exciting category');
|
|
event.should.have.property('level').equal(levels.DEBUG);
|
|
event.should.have.property('data').eql(["interesting thing"]);
|
|
event.should.have.property('startTime');
|
|
});
|
|
});
|
|
|
|
});
|
|
|