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

@@ -74,41 +74,53 @@ describe('XML node', function() {
n1.receive({payload:obj,topic: "bar"});
});
});
// HELEN - commenting out for now
// it('should log an error if asked to parse an invalid xml string', function(done) {
// var flow = [{id:"n1",type:"xml",wires:[["n2"]],func:"return msg;"},
// {id:"n2", type:"helper"}];
// helper.load(xmlNode, flow, function() {
// var n1 = helper.getNode("n1");
// var n2 = helper.getNode("n2");
// n1.on("log", function(msg) {
// if (msg.level && (msg.level === 'metric')) {
// // do nothing as we've just hit a metric related msg
// } else {
// should.deepEqual("error", msg.level);
// done();
// }
// });
// n1.receive({payload:'<not valid xml>',topic: "bar"});
// });
// });
// HELEN - commenting out for now
// it('should log an error if asked to parse something thats not xml or js', function(done) {
// var flow = [{id:"n1",type:"xml",wires:[["n2"]],func:"return msg;"},
// {id:"n2", type:"helper"}];
// helper.load(xmlNode, flow, function() {
// var n1 = helper.getNode("n1");
// var n2 = helper.getNode("n2");
// n1.on("log", function(msg) {
// if (msg.level && (msg.level === 'metric')) {
// // do nothing as we've just hit a metric related msg
// } else {msg.should.have.property('msg');
// should.deepEqual("This node only handles xml strings or js objects.", msg.msg);
// done();
// }
// });
// n1.receive({payload:1,topic: "bar"});
// });
// });
it('should log an error if asked to parse an invalid xml string', function(done) {
var flow = [{id:"n1",type:"xml",wires:[["n2"]],func:"return msg;"},
{id:"n2", type:"helper"}];
helper.load(xmlNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n1.receive({payload:'<not valid xml>',topic: "bar"});
setTimeout(function() {
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);
logEvents[0][0].should.have.a.property('msg');
logEvents[0][0].msg.toString().should.startWith("Error: Attribute without value");
done();
} catch(err) {
done(err);
}
},200);
});
});
it('should log an error if asked to parse something thats not xml or js', function(done) {
var flow = [{id:"n1",type:"xml",wires:[["n2"]],func:"return msg;"},
{id:"n2", type:"helper"}];
helper.load(xmlNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n1.receive({payload:1,topic: "bar"});
setTimeout(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);
logEvents[0][0].should.have.a.property('msg',"This node only handles xml strings or js objects.");
done();
} catch(err) {
done(err);
}
},200);
});
});
});