mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Update Function catch tests to handle async receive
This commit is contained in:
parent
b734097d16
commit
a17325f028
@ -282,13 +282,13 @@ module.exports = function(RED) {
|
||||
if (!errorMessage) {
|
||||
errorMessage = err.toString();
|
||||
}
|
||||
this.error(errorMessage, msg);
|
||||
done(errorMessage);
|
||||
}
|
||||
else if (typeof err === "string") {
|
||||
this.error(err, msg);
|
||||
done(err);
|
||||
}
|
||||
else {
|
||||
this.error(JSON.stringify(err), msg);
|
||||
done(JSON.stringify(err));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1412,6 +1412,7 @@ describe('function node', function() {
|
||||
helper.load(functionNode, flow, function () {
|
||||
var n1 = helper.getNode("n1");
|
||||
n1.receive({payload: "foo", topic: "bar"});
|
||||
setTimeout(function() {
|
||||
try {
|
||||
helper.log().called.should.be.true();
|
||||
var logEvents = helper.log().args.filter(function (evt) {
|
||||
@ -1427,6 +1428,7 @@ describe('function node', function() {
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
},50);
|
||||
});
|
||||
});
|
||||
it('should catch thrown number', function (done) {
|
||||
@ -1434,6 +1436,7 @@ describe('function node', function() {
|
||||
helper.load(functionNode, flow, function () {
|
||||
var n1 = helper.getNode("n1");
|
||||
n1.receive({payload: "foo", topic: "bar"});
|
||||
setTimeout(function() {
|
||||
try {
|
||||
helper.log().called.should.be.true();
|
||||
var logEvents = helper.log().args.filter(function (evt) {
|
||||
@ -1449,13 +1452,15 @@ describe('function node', function() {
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
},50);
|
||||
});
|
||||
});
|
||||
it('should catch thrown object (bad practise)', function (done) {
|
||||
it('should catch thrown object (bad practice)', function (done) {
|
||||
var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "throw {a:1};"}];
|
||||
helper.load(functionNode, flow, function () {
|
||||
var n1 = helper.getNode("n1");
|
||||
n1.receive({payload: "foo", topic: "bar"});
|
||||
setTimeout(function() {
|
||||
try {
|
||||
helper.log().called.should.be.true();
|
||||
var logEvents = helper.log().args.filter(function (evt) {
|
||||
@ -1471,6 +1476,7 @@ describe('function node', function() {
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
},50);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user