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); }); }); });