more linting
This commit is contained in:
parent
9853e13429
commit
e5dba219d1
@ -1,5 +1,6 @@
|
|||||||
var vows = require('vows'),
|
"use strict";
|
||||||
assert = require('assert');
|
var vows = require('vows')
|
||||||
|
, assert = require('assert');
|
||||||
|
|
||||||
//used for patternLayout tests.
|
//used for patternLayout tests.
|
||||||
function test(args, pattern, value) {
|
function test(args, pattern, value) {
|
||||||
@ -25,7 +26,7 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.equal(output, '\033[31m[2010-12-05 14:18:30.045] [ERROR] cheese - \033[39mnonsense');
|
assert.equal(output, '\0x1B[31m[2010-12-05 14:18:30.045] [ERROR] cheese - \0x1B[39mnonsense');
|
||||||
},
|
},
|
||||||
|
|
||||||
'should support the console.log format for the message': function(layout) {
|
'should support the console.log format for the message': function(layout) {
|
||||||
@ -37,7 +38,7 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.equal(output, '\033[31m[2010-12-05 14:18:30.045] [ERROR] cheese - \033[39mthing 2');
|
assert.equal(output, '\0x1B[31m[2010-12-05 14:18:30.045] [ERROR] cheese - \0x1B[39mthing 2');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -58,34 +59,34 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
},
|
},
|
||||||
'should support the console.log format for the message' : function(layout) {
|
'should support the console.log format for the message' : function(layout) {
|
||||||
assert.equal(layout({
|
assert.equal(layout({
|
||||||
data: ["thing %d", 1, "cheese"]
|
data: ["thing %d", 1, "cheese"],
|
||||||
, startTime: new Date(2010, 11, 5, 14, 18, 30, 45)
|
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
||||||
, categoryName: "cheese"
|
categoryName: "cheese",
|
||||||
, level : {
|
level : {
|
||||||
colour: "green"
|
colour: "green",
|
||||||
, toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
}), "thing 1 'cheese'");
|
}), "thing 1 'cheese'");
|
||||||
},
|
},
|
||||||
'should output the first item even if it is not a string': function(layout) {
|
'should output the first item even if it is not a string': function(layout) {
|
||||||
assert.equal(layout({
|
assert.equal(layout({
|
||||||
data: [ { thing: 1} ]
|
data: [ { thing: 1} ],
|
||||||
, startTime: new Date(2010, 11, 5, 14, 18, 30, 45)
|
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
||||||
, categoryName: "cheese"
|
categoryName: "cheese",
|
||||||
, level: {
|
level: {
|
||||||
colour: "green"
|
colour: "green",
|
||||||
, toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
}), "{ thing: 1 }");
|
}), "{ thing: 1 }");
|
||||||
},
|
},
|
||||||
'should print the stacks of a passed error objects': function(layout) {
|
'should print the stacks of a passed error objects': function(layout) {
|
||||||
assert.isArray(layout({
|
assert.isArray(layout({
|
||||||
data: [ new Error() ]
|
data: [ new Error() ],
|
||||||
, startTime: new Date(2010, 11, 5, 14, 18, 30, 45)
|
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
||||||
, categoryName: "cheese"
|
categoryName: "cheese",
|
||||||
, level: {
|
level: {
|
||||||
colour: "green"
|
colour: "green",
|
||||||
, toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
}).match(/Error\s+at Object\..*\s+\((.*)test[\\\/]layouts-test\.js\:\d+\:\d+\)\s+at runTest/)
|
}).match(/Error\s+at Object\..*\s+\((.*)test[\\\/]layouts-test\.js\:\d+\:\d+\)\s+at runTest/)
|
||||||
, 'regexp did not return a match');
|
, 'regexp did not return a match');
|
||||||
@ -94,15 +95,15 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
{ topic:
|
{ topic:
|
||||||
function(layout){
|
function(layout){
|
||||||
var e = new Error("My Unique Error Message");
|
var e = new Error("My Unique Error Message");
|
||||||
e.augmented = "My Unique attribute value"
|
e.augmented = "My Unique attribute value";
|
||||||
e.augObj = { at1: "at2" }
|
e.augObj = { at1: "at2" };
|
||||||
return layout({
|
return layout({
|
||||||
data: [ e ]
|
data: [ e ],
|
||||||
, startTime: new Date(2010, 11, 5, 14, 18, 30, 45)
|
startTime: new Date(2010, 11, 5, 14, 18, 30, 45),
|
||||||
, categoryName: "cheese"
|
categoryName: "cheese",
|
||||||
, level: {
|
level: {
|
||||||
colour: "green"
|
colour: "green",
|
||||||
, toString: function() { return "ERROR"; }
|
toString: function() { return "ERROR"; }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -150,7 +151,10 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
lines = output.split(/\n/);
|
lines = output.split(/\n/);
|
||||||
|
|
||||||
assert.equal(lines.length - 1, stack.length);
|
assert.equal(lines.length - 1, stack.length);
|
||||||
assert.equal(lines[0], "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test [Error: Some made-up error]");
|
assert.equal(
|
||||||
|
lines[0],
|
||||||
|
"[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test [Error: Some made-up error]"
|
||||||
|
);
|
||||||
|
|
||||||
for (var i = 1; i < stack.length; i++) {
|
for (var i = 1; i < stack.length; i++) {
|
||||||
assert.equal(lines[i+2], stack[i+1]);
|
assert.equal(lines[i+2], stack[i+1]);
|
||||||
@ -163,7 +167,11 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
message: 'Gorgonzola smells.'
|
message: 'Gorgonzola smells.'
|
||||||
}];
|
}];
|
||||||
output = layout(event);
|
output = layout(event);
|
||||||
assert.equal(output, "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test { name: 'Cheese', message: 'Gorgonzola smells.' }");
|
assert.equal(
|
||||||
|
output,
|
||||||
|
"[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test " +
|
||||||
|
"{ name: 'Cheese', message: 'Gorgonzola smells.' }"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -250,7 +258,7 @@ vows.describe('log4js layouts').addBatch({
|
|||||||
test(args, '%-10p', 'DEBUG ');
|
test(args, '%-10p', 'DEBUG ');
|
||||||
},
|
},
|
||||||
'%[%r%] should output colored time': function(args) {
|
'%[%r%] should output colored time': function(args) {
|
||||||
test(args, '%[%r%]', '\033[36m14:18:30\033[39m');
|
test(args, '%[%r%]', '\0x1B[36m14:18:30\0x1B[39m');
|
||||||
},
|
},
|
||||||
'%x{testString} should output the string stored in tokens': function(args) {
|
'%x{testString} should output the string stored in tokens': function(args) {
|
||||||
test(args, '%x{testString}', 'testStringToken');
|
test(args, '%x{testString}', 'testStringToken');
|
||||||
|
Loading…
Reference in New Issue
Block a user