From efc80a895c7a12fd6eff4ce7f2bb76d1aba100d6 Mon Sep 17 00:00:00 2001 From: Craig Taub Date: Sun, 3 May 2020 13:18:49 +0100 Subject: [PATCH] Disable if setting == or grtr to upper --- lib/runnable.js | 10 ++++++++-- test/unit/runnable.spec.js | 20 ++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/runnable.js b/lib/runnable.js index ced40be753..ed585eb93f 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -80,8 +80,14 @@ Runnable.prototype.timeout = function(ms) { var range = [0, INT_MAX]; ms = utils.clamp(ms, range); - debug('timeout %d', ms); - this._timeout = ms; + // see #1652 for reasoning + if (ms === range[0] || ms === range[1]) { + this._timeout = 0; + } else { + this._timeout = ms; + } + debug('timeout %d', this._timeout); + if (this.timer) { this.resetTimeout(); } diff --git a/test/unit/runnable.spec.js b/test/unit/runnable.spec.js index 417b3039c9..fa328441ca 100644 --- a/test/unit/runnable.spec.js +++ b/test/unit/runnable.spec.js @@ -74,14 +74,8 @@ describe('Runnable(title, fn)', function() { run.timeout(MAX_TIMEOUT); }); describe('given numeric value', function() { - it('should set the timeout value', function() { - expect(run.timeout(), 'to be', MAX_TIMEOUT); - }); - }); - - describe('given string timestamp', function() { - it('should set the timeout value', function() { - expect(run.timeout(), 'to be', MAX_TIMEOUT); + it('should set the disabled timeout value', function() { + expect(run.timeout(), 'to be', 0); }); }); }); @@ -96,14 +90,8 @@ describe('Runnable(title, fn)', function() { }); describe('given numeric value', function() { - it('should clamp the value to max timeout', function() { - expect(run.timeout(), 'to be', MAX_TIMEOUT); - }); - }); - - describe('given string timestamp', function() { - it('should clamp the value to max timeout', function() { - expect(run.timeout(), 'to be', MAX_TIMEOUT); + it('should set the disabled timeout value', function() { + expect(run.timeout(), 'to be', 0); }); }); });