Skip to content

Commit

Permalink
Merge pull request #2336 from boneskull/issue/2311
Browse files Browse the repository at this point in the history
ensures slow() called w/o args does not blast value; closes #2311
  • Loading branch information
boneskull committed Jun 28, 2016
2 parents 0fe8133 + 55efba4 commit 84dcb6d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/runnable.js
Expand Up @@ -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') {
Expand Down
25 changes: 20 additions & 5 deletions test/runnable.js
Expand Up @@ -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(){
Expand Down

0 comments on commit 84dcb6d

Please sign in to comment.