improved test coverage
This commit is contained in:
@@ -331,5 +331,20 @@ describe('log4js layouts', function() {
|
|||||||
assert.ok(layouts.layout("coloured"));
|
assert.ok(layouts.layout("coloured"));
|
||||||
assert.ok(layouts.layout("pattern"));
|
assert.ok(layouts.layout("pattern"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return falsy if a layout does not exist', function() {
|
||||||
|
assert.ok(!layouts.layout("cheese"));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass config to layouts that need it', function() {
|
||||||
|
var layout = layouts.layout(
|
||||||
|
"pattern",
|
||||||
|
{
|
||||||
|
pattern: "%m"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(layout({ data: [ "blah" ] }), "blah");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ describe('log level filter', function() {
|
|||||||
'../lib/log4js',
|
'../lib/log4js',
|
||||||
{ requires:
|
{ requires:
|
||||||
{ './appenders/console': function() {
|
{ './appenders/console': function() {
|
||||||
return function() { return function(evt) { events.push(evt); }; }; }
|
return function() {
|
||||||
|
return function(evt) { events.push(evt); };
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -107,7 +110,7 @@ describe('log level filter', function() {
|
|||||||
"errors": {
|
"errors": {
|
||||||
type: "logLevelFilter",
|
type: "logLevelFilter",
|
||||||
allow: [ "cheese", "biscuits", "ERROR" ],
|
allow: [ "cheese", "biscuits", "ERROR" ],
|
||||||
appender: { type: "console" }
|
appender: "console"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
categories: {
|
categories: {
|
||||||
@@ -116,4 +119,23 @@ describe('log level filter', function() {
|
|||||||
});
|
});
|
||||||
}).should.throw(/Unrecognised log level 'cheese'\./);
|
}).should.throw(/Unrecognised log level 'cheese'\./);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should complain if the list of levels is empty', function() {
|
||||||
|
(function() {
|
||||||
|
log4js.configure({
|
||||||
|
appenders: {
|
||||||
|
"console": { type: "console" },
|
||||||
|
"errors": {
|
||||||
|
type: "logLevelFilter",
|
||||||
|
allow: [],
|
||||||
|
appender: "console"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
categories: {
|
||||||
|
default: { level: "debug", appenders: [ "errors" ] }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).should.throw(/No allowed log levels specified\./);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user