1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix random delay in milliseconds case and change test to reproduce bug.

Because there was no multiplier the node.randomFirst was a string so
the later '+' was a concatentation. The test failed to catch this because
it uses integers not strings to configure the node.
This commit is contained in:
Mark Hindess 2015-01-14 10:18:47 +00:00
parent eee2996e8a
commit 7909ca24d3
2 changed files with 3 additions and 3 deletions

View File

@ -62,8 +62,8 @@ module.exports = function(RED) {
} }
if (n.randomUnits === "milliseconds") { if (n.randomUnits === "milliseconds") {
this.randomFirst = n.randomFirst; this.randomFirst = n.randomFirst * 1;
this.randomLast = n.randomLast; this.randomLast = n.randomLast * 1;
} else if (n.randomUnits === "seconds") { } else if (n.randomUnits === "seconds") {
this.randomFirst = n.randomFirst * 1000; this.randomFirst = n.randomFirst * 1000;
this.randomLast = n.randomLast * 1000; this.randomLast = n.randomLast * 1000;

View File

@ -368,7 +368,7 @@ describe('delayNode', function() {
}); });
it(' randomly delays the message in milliseconds', function(done) { it(' randomly delays the message in milliseconds', function(done) {
randomDelayTest(400, 800, "milliseconds", done); randomDelayTest("400", "800", "milliseconds", done);
}); });
it('randomly delays the message in minutes', function(done) { it('randomly delays the message in minutes', function(done) {