Renable unit tests following logging api changes

This commit is contained in:
Nick O'Leary
2015-01-29 09:57:09 +00:00
parent 109270b437
commit f983e4da9f
6 changed files with 180 additions and 145 deletions

View File

@@ -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" }];

View File

@@ -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);
}
});
});
});