Skip to content

Commit

Permalink
Correct erroneous test
Browse files Browse the repository at this point in the history
Because the Runnable under test is not part of a Suite, its context is
undefined. Prior to this commit, the error returned was a
runtime-generated `ReferenceError`, not a Mocha-generated `Error`.

Set the timeout via the `Runnable#timeout` method, and update the test
to assert the correct behavior (not implementation details such as the
message body of the generated error).
  • Loading branch information
jugglinmike committed Nov 25, 2013
1 parent 30ba8f5 commit ddf218e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/runnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,18 @@ describe('Runnable(title, fn)', function(){
})

it('should allow updating the timeout', function(done){
var callCount = 0;
var increment = function() {
callCount++;
};
var test = new Runnable('foo', function(done){
this.timeout(10);
setTimeout(increment, 1);
setTimeout(increment, 100);
});
test.timeout(10);
test.run(function(err){
err.message.should.include('timeout');
err.should.be.ok;
callCount.should.equal(1);
done();
});
})
Expand Down

0 comments on commit ddf218e

Please sign in to comment.