mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #1823 from node-red-hitachi/fix-referenceerror
Fix the ReferenceError in change node
This commit is contained in:
commit
8226f1fa75
@ -166,12 +166,10 @@ module.exports = function(RED) {
|
|||||||
try {
|
try {
|
||||||
fromRE = new RegExp(fromRE, "g");
|
fromRE = new RegExp(fromRE, "g");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(new Error(RED._("change.errors.invalid-from",{error:e.message})));
|
return Promise.reject(new Error(RED._("change.errors.invalid-from",{error:e.message})));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(RED._("change.errors.invalid-from",{error:"unsupported type: "+(typeof fromValue)})));
|
return Promise.reject(new Error(RED._("change.errors.invalid-from",{error:"unsupported type: "+(typeof fromValue)})));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
fromType,
|
fromType,
|
||||||
|
@ -1272,6 +1272,25 @@ describe('change Node', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reports invalid fromValue', function(done) {
|
||||||
|
var flow = [{"id":"changeNode1","type":"change",rules:[{"t":"change","p":"payload","from":"null","fromt":"msg","to":"abc","tot":"str"}],"name":"changeNode","wires":[["helperNode1"]]},
|
||||||
|
{id:"helperNode1", type:"helper", wires:[]}];
|
||||||
|
helper.load(changeNode, flow, function() {
|
||||||
|
var changeNode1 = helper.getNode("changeNode1");
|
||||||
|
setTimeout(function() {
|
||||||
|
var logEvents = helper.log().args.filter(function (evt) {
|
||||||
|
return evt[0].type == "change";
|
||||||
|
});
|
||||||
|
logEvents.should.have.length(1);
|
||||||
|
var msg = logEvents[0][0];
|
||||||
|
msg.should.have.property('level', helper.log().ERROR);
|
||||||
|
msg.should.have.property('id', 'changeNode1');
|
||||||
|
done();
|
||||||
|
},25);
|
||||||
|
changeNode1.receive({payload:"",null:null});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('env var', function() {
|
describe('env var', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
process.env.NR_TEST_A = 'foo';
|
process.env.NR_TEST_A = 'foo';
|
||||||
|
Loading…
Reference in New Issue
Block a user