mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add unit tests for Join restartTimeout and update help
This commit is contained in:
parent
5df0dae11a
commit
ec27e19e3f
@ -93,6 +93,10 @@
|
|||||||
<dt class="optional">complete</dt>
|
<dt class="optional">complete</dt>
|
||||||
<dd>If set, the node will append the payload, and then send the output message in its current state.
|
<dd>If set, the node will append the payload, and then send the output message in its current state.
|
||||||
If you don't wish to append the payload, delete it from the msg.</dd>
|
If you don't wish to append the payload, delete it from the msg.</dd>
|
||||||
|
<dt class="optional">reset</dt>
|
||||||
|
<dd>If set, the node will clear any partially complete message and not send it.</dd>
|
||||||
|
<dt class="optional">restartTimeout</dt>
|
||||||
|
<dd>If set, and the node has a timeout configured, that timeout will be restarted.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
|
|
||||||
@ -115,7 +119,8 @@
|
|||||||
<p>A <i>count</i> can be set for how many messages should be received before generating the output message.
|
<p>A <i>count</i> can be set for how many messages should be received before generating the output message.
|
||||||
For object outputs, once this count has been reached, the node can be configured to send a message for each subsequent message
|
For object outputs, once this count has been reached, the node can be configured to send a message for each subsequent message
|
||||||
received.</p>
|
received.</p>
|
||||||
<p>A <i>timeout</i> can be set to trigger sending the new message using whatever has been received so far. This timeout can be restarted and set to its initial value by sending a message with the <code>msg.restartTimeout</code> property set.</p>
|
<p>A <i>timeout</i> can be set to trigger sending the new message using whatever has been received so far.
|
||||||
|
This timeout can be restarted by sending a message with the <code>msg.restartTimeout</code> property set.</p>
|
||||||
<p>If a message is received with the <code>msg.complete</code> property set, the output message is finalised and sent.
|
<p>If a message is received with the <code>msg.complete</code> property set, the output message is finalised and sent.
|
||||||
This resets any part counts.</p>
|
This resets any part counts.</p>
|
||||||
<p>If a message is received with the <code>msg.reset</code> property set, the partly complete message is deleted and not sent.
|
<p>If a message is received with the <code>msg.reset</code> property set, the partly complete message is deleted and not sent.
|
||||||
|
@ -798,6 +798,33 @@ describe('JOIN node', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow the timeout to be restarted', function(done) {
|
||||||
|
var flow = [{id:"n1", type:"join", wires:[["n2"]], build:"string", timeout:0.5, count:"", joiner:",",mode:"custom"},
|
||||||
|
{id:"n2", type:"helper"}];
|
||||||
|
helper.load(joinNode, flow, function() {
|
||||||
|
var n1 = helper.getNode("n1");
|
||||||
|
var n2 = helper.getNode("n2");
|
||||||
|
n2.on("input", function(msg) {
|
||||||
|
try {
|
||||||
|
msg.should.have.property("payload");
|
||||||
|
msg.payload.should.equal("a,b,c");
|
||||||
|
const timeTaken = (Date.now() - start)/1000;
|
||||||
|
// Node times out after 0.5s.
|
||||||
|
// It receives a restartTimeout after 0.4s.
|
||||||
|
// So time taken to timeout should be approx 0.9
|
||||||
|
timeTaken.should.be.approximately(0.9,0.15);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
catch(e) { done(e) }
|
||||||
|
});
|
||||||
|
var start = Date.now();
|
||||||
|
n1.receive({payload:"a"});
|
||||||
|
setTimeout(function() {
|
||||||
|
n1.receive({payload:"b", restartTimeout: true});
|
||||||
|
n1.receive({payload:"c"});
|
||||||
|
},400);
|
||||||
|
});
|
||||||
|
});
|
||||||
it('should join strings with a specifed character and complete when told to', function(done) {
|
it('should join strings with a specifed character and complete when told to', function(done) {
|
||||||
var flow = [{id:"n1", type:"join", wires:[["n2"]], build:"string", timeout:5, count:0, joiner:"\n",mode:"custom"},
|
var flow = [{id:"n1", type:"join", wires:[["n2"]], build:"string", timeout:5, count:0, joiner:"\n",mode:"custom"},
|
||||||
{id:"n2", type:"helper"}];
|
{id:"n2", type:"helper"}];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user