mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Renable unit tests following logging api changes
This commit is contained in:
@@ -54,34 +54,35 @@ describe('debug node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
// HELEN - commenting out for now
|
||||
// it('should publish to console', function(done) {
|
||||
// var flow = [{id:"n1", type:"debug", console: "true" }];
|
||||
// helper.load(debugNode, flow, function() {
|
||||
// var n1 = helper.getNode("n1");
|
||||
// var count = 0;
|
||||
// n1.on('log', function(msg) {
|
||||
// var tstmp = msg._timestamp;
|
||||
// msg.should.eql({level:'log',id:'n1',type:'debug',msg:'test', _timestamp:tstmp});
|
||||
// count++;
|
||||
// if (count == 2) {
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
// websocket_test(function() {
|
||||
// n1.emit("input", {payload:"test"});
|
||||
// }, function(msg) {
|
||||
// JSON.parse(msg).should.eql({
|
||||
// topic:"debug",data:{id:"n1",msg:"test",property:"payload"}
|
||||
// });
|
||||
// count++;
|
||||
// }, function() {
|
||||
// if (count == 2) {
|
||||
// done();
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
it('should publish to console', function(done) {
|
||||
var flow = [{id:"n1", type:"debug", console: "true" }];
|
||||
helper.load(debugNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var count = 0;
|
||||
websocket_test(function() {
|
||||
n1.emit("input", {payload:"test"});
|
||||
}, function(msg) {
|
||||
JSON.parse(msg).should.eql({
|
||||
topic:"debug",data:{id:"n1",msg:"test",property:"payload"}
|
||||
});
|
||||
count++;
|
||||
}, function() {
|
||||
try {
|
||||
helper.log().called.should.be.true;
|
||||
var logEvents = helper.log().args.filter(function(evt) {
|
||||
return evt[0].level == "log";
|
||||
});
|
||||
logEvents.should.have.length(1);
|
||||
var tstmp = logEvents[0][0].timestamp;
|
||||
logEvents[0][0].should.eql({level:'log',id:'n1',type:'debug',msg:'test', timestamp:tstmp});
|
||||
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should publish complete message', function(done) {
|
||||
var flow = [{id:"n1", type:"debug", complete: "true" }];
|
||||
|
@@ -131,23 +131,27 @@ describe('function node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
// HELEN - commenting out for now
|
||||
// it('should handle and log script error', function(done) {
|
||||
// var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"retunr"}];
|
||||
// helper.load(functionNode, flow, function() {
|
||||
// var n1 = helper.getNode("n1");
|
||||
// n1.on("log", function(msg) {
|
||||
// if (msg.level === 'error') {
|
||||
// msg.should.have.property('level', 'error');
|
||||
// msg.should.have.property('id', 'n1');
|
||||
// msg.should.have.property('type', 'function');
|
||||
// msg.should.have.property('msg', 'ReferenceError: retunr is not defined');
|
||||
// done();
|
||||
// }
|
||||
//
|
||||
// });
|
||||
// n1.receive({payload:"foo",topic: "bar"});
|
||||
// });
|
||||
// });
|
||||
it('should handle and log script error', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"retunr"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
n1.receive({payload:"foo",topic: "bar"});
|
||||
try {
|
||||
helper.log().called.should.be.true;
|
||||
var logEvents = helper.log().args.filter(function(evt) {
|
||||
return evt[0].level == "error";
|
||||
});
|
||||
logEvents.should.have.length(1);
|
||||
var msg = logEvents[0][0];
|
||||
msg.should.have.property('level', 'error');
|
||||
msg.should.have.property('id', 'n1');
|
||||
msg.should.have.property('type', 'function');
|
||||
msg.should.have.property('msg', 'ReferenceError: retunr is not defined');
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user