mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3660 from Steve-Mcl/backport-3632
Fix JSONata evaluation of inject button (Backport 3632 to v2.x)
This commit is contained in:
commit
9d39709038
@ -109,9 +109,10 @@ module.exports = function(RED) {
|
|||||||
if (!property) return;
|
if (!property) return;
|
||||||
|
|
||||||
if (valueType === "jsonata") {
|
if (valueType === "jsonata") {
|
||||||
if (p.exp) {
|
if (p.v) {
|
||||||
try {
|
try {
|
||||||
var val = RED.util.evaluateJSONataExpression(p.exp, msg);
|
var exp = RED.util.prepareJSONataExpression(p.v, node);
|
||||||
|
var val = RED.util.evaluateJSONataExpression(exp, msg);
|
||||||
RED.util.setMessageProperty(msg, property, val, true);
|
RED.util.setMessageProperty(msg, property, val, true);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
@ -906,6 +906,7 @@ describe('inject node', function() {
|
|||||||
msg.should.have.property("str1", "1"); //injected prop
|
msg.should.have.property("str1", "1"); //injected prop
|
||||||
msg.should.have.property("num1", 1); //injected prop
|
msg.should.have.property("num1", 1); //injected prop
|
||||||
msg.should.have.property("bool1", true); //injected prop
|
msg.should.have.property("bool1", true); //injected prop
|
||||||
|
msg.should.have.property("jsonata1", "AB"); //injected prop
|
||||||
|
|
||||||
helper.clearFlows().then(function() {
|
helper.clearFlows().then(function() {
|
||||||
done();
|
done();
|
||||||
@ -919,6 +920,7 @@ describe('inject node', function() {
|
|||||||
{p:"str1", v:"1", vt:"str"}, //new prop
|
{p:"str1", v:"1", vt:"str"}, //new prop
|
||||||
{p:"num1", v:"1", vt:"num"}, //new prop
|
{p:"num1", v:"1", vt:"num"}, //new prop
|
||||||
{p:"bool1", v:"true", vt:"bool"}, //new prop
|
{p:"bool1", v:"true", vt:"bool"}, //new prop
|
||||||
|
{p:"jsonata1", v:'"A" & "B"', vt:"jsonata"}, //new prop
|
||||||
]})
|
]})
|
||||||
.expect(200).end(function(err) {
|
.expect(200).end(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user