From 01b67c692b081921e51ed9d52fedce8314c15fd1 Mon Sep 17 00:00:00 2001 From: martinb Date: Thu, 12 Nov 2020 18:51:14 +0100 Subject: [PATCH] add test case for support of out of order messages support in auto mode of join node if exactly one message has count set --- test/nodes/core/sequence/17-split_spec.js | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/nodes/core/sequence/17-split_spec.js b/test/nodes/core/sequence/17-split_spec.js index 2c45f0e02..8369a70a6 100644 --- a/test/nodes/core/sequence/17-split_spec.js +++ b/test/nodes/core/sequence/17-split_spec.js @@ -1646,4 +1646,40 @@ describe('JOIN node', function() { }); }); + it('should handle msg.parts even if messages are out of order in auto mode if exactly one message has count set', function (done) { + var flow = [{ id: "n1", type: "join", wires: [["n2"]], joiner: "[44]", joinerType: "bin", build: "string", mode: "auto" }, + { id: "n2", type: "helper" }]; + helper.load(joinNode, flow, function () { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + + n2.on("input", function (msg) { + msg.payload.length.should.be.eql(5); + msg.payload.should.be.eql([0,1,2,3,4]); + done(); + }); + + var msg = {}; + msg.parts = { + id: RED.util.generateId() + }; + for(var elem = 1; elem < 5; ++elem) { + var _msg = RED.util.cloneMessage(msg); + _msg.parts.index = elem; + if(elem == 4) { + _msg.parts.count = 5; + } + _msg.payload = elem; + n1.receive(_msg); + } + + var _msg = RED.util.cloneMessage(msg); + delete _msg.parts.count; + _msg.parts.index = 0; + _msg.payload = 0; + n1.receive(_msg); + }); + + }) + });