From 7909ca24d38a11c42b790936a95fb423f473b557 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 14 Jan 2015 10:18:47 +0000 Subject: [PATCH] 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. --- nodes/core/core/89-delay.js | 4 ++-- test/nodes/core/core/89-delay_spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nodes/core/core/89-delay.js b/nodes/core/core/89-delay.js index dfc5616ae..3a299caeb 100644 --- a/nodes/core/core/89-delay.js +++ b/nodes/core/core/89-delay.js @@ -62,8 +62,8 @@ module.exports = function(RED) { } if (n.randomUnits === "milliseconds") { - this.randomFirst = n.randomFirst; - this.randomLast = n.randomLast; + this.randomFirst = n.randomFirst * 1; + this.randomLast = n.randomLast * 1; } else if (n.randomUnits === "seconds") { this.randomFirst = n.randomFirst * 1000; this.randomLast = n.randomLast * 1000; diff --git a/test/nodes/core/core/89-delay_spec.js b/test/nodes/core/core/89-delay_spec.js index 22c3173a5..87ca6088f 100644 --- a/test/nodes/core/core/89-delay_spec.js +++ b/test/nodes/core/core/89-delay_spec.js @@ -368,7 +368,7 @@ describe('delayNode', function() { }); 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) {