-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1520 from dasilvacontin/fix/1496
In .run(fn), check if fn exists before executing the callback, fixes #1496
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var Mocha = require('../'); | ||
var Test = Mocha.Test; | ||
|
||
describe('Mocha', function(){ | ||
var blankOpts = { reporter: function(){} }; // no output | ||
|
||
describe('.run(fn)', function(){ | ||
it('should not raise errors if callback was not provided', function(){ | ||
var mocha = new Mocha(blankOpts); | ||
mocha.run(); | ||
}) | ||
|
||
it('should execute the callback when complete', function(done) { | ||
var mocha = new Mocha(blankOpts); | ||
mocha.run(function(){ | ||
done(); | ||
}) | ||
}) | ||
|
||
it('should execute the callback with the number of failures '+ | ||
'as parameter', function(done) { | ||
var mocha = new Mocha(blankOpts); | ||
var failingTest = new Test('failing test', function(){ | ||
throw new Error('such fail'); | ||
}); | ||
mocha.suite.addTest(failingTest); | ||
mocha.run(function(failures) { | ||
failures.should.equal(1); | ||
done(); | ||
}); | ||
}) | ||
}) | ||
}) |