☕️ Classic, reliable, trusted test framework for Node.js and the browser
ensures slow() called w/o args does not blast value; closes #2311
Christopher Hiller55efba470ac8
diff --git a/lib/runnable.js b/lib/runnable.jsindex 64de4e9a..bba47d95 100644--- a/lib/runnable.js+++ b/lib/runnable.js@@ -96,7 +96,7 @@ Runnable.prototype.timeout = function(ms) {* @return {Runnable|number} ms or Runnable instance.*/Runnable.prototype.slow = function(ms) {- if (!arguments.length) {+ if (typeof ms === 'undefined') {return this._slow;}if (typeof ms === 'string') {diff --git a/test/runnable.js b/test/runnable.jsindex af34d064..a3d88add 100644--- a/test/runnable.js+++ b/test/runnable.js@@ -49,12 +49,27 @@ describe('Runnable(title, fn)', function(){});});- describe('#slow(ms)', function(){- it('should set the slow threshold', function(){- var run = new Runnable;- run.slow(100)+ describe('#slow(ms)', function() {+ var run;++ beforeEach(function() {+ run = new Runnable();+ });++ it('should set the slow threshold', function() {+ run.slow(100);run.slow().should.equal(100);- })+ });++ it('should not set the slow threshold if the parameter is not passed', function() {+ run.slow();+ run.slow().should.equal(75);+ });++ it('should not set the slow threshold if the parameter is undefined', function() {+ run.slow(undefined);+ run.slow().should.equal(75);+ });})describe('.title', function(){