Ensure trigger second output is revaluated for date types

This commit is contained in:
Nick O'Leary 2024-10-21 16:35:11 +01:00
parent b3aff3a3e6
commit 2220956007
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 2 additions and 2 deletions

View File

@ -201,7 +201,7 @@ module.exports = function(RED) {
if (node.op2type !== "nul") { if (node.op2type !== "nul") {
var promise = Promise.resolve(); var promise = Promise.resolve();
msg2 = RED.util.cloneMessage(msg); msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") { if (node.op2type === "flow" || node.op2type === "global" || node.op2type === "date") {
promise = new Promise((resolve,reject) => { promise = new Promise((resolve,reject) => {
RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg,(err,value) => { RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg,(err,value) => {
if (err) { if (err) {

View File

@ -152,7 +152,7 @@ describe('trigger node', function() {
if (rval) { if (rval) {
msg.should.have.property("payload"); msg.should.have.property("payload");
if (type == "date" && val == "0") { if (type == "date" && val == "0") {
should.deepEqual(Math.round(msg.payload/1000000), parseInt(Date.now()/1000000)); ;(Math.round(msg.payload/1000000)).should.be.approximately(parseInt(Date.now()/1000000), 1);
} }
else if (type == "date" && val == "iso") { else if (type == "date" && val == "iso") {
should.deepEqual(msg.payload.substr(0,11), rval.substr(0,11)); should.deepEqual(msg.payload.substr(0,11), rval.substr(0,11));