|
|
@ -4,7 +4,6 @@ var assert = require('assert'); |
|
|
|
var EventEmitter = require('events').EventEmitter; |
|
|
|
var fnName = require('fn-name'); |
|
|
|
var claim = require('claim'); |
|
|
|
var objectAssign = require('object-assign'); |
|
|
|
|
|
|
|
/** |
|
|
|
* Initialize a new `Test` |
|
|
@ -30,19 +29,26 @@ function Test(title, fn) { |
|
|
|
this.fn = fn; |
|
|
|
this.assertCount = 0; |
|
|
|
this.planCount = null; |
|
|
|
|
|
|
|
// TODO: find a better way to count assertions
|
|
|
|
this.onAssert(function () { |
|
|
|
if (++this.assertCount === this.planCount) { |
|
|
|
setImmediate(this.exit.bind(this)); |
|
|
|
} |
|
|
|
}.bind(this)); |
|
|
|
} |
|
|
|
|
|
|
|
util.inherits(Test, EventEmitter); |
|
|
|
objectAssign(Test.prototype, claim); |
|
|
|
module.exports = Test; |
|
|
|
|
|
|
|
Test.prototype._assert = function () { |
|
|
|
if (++this.assertCount === this.planCount) { |
|
|
|
setImmediate(this.exit.bind(this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: find a better way to count assertions
|
|
|
|
// decorate the `claim` methods with our assert counter
|
|
|
|
Object.keys(claim).forEach(function (el) { |
|
|
|
Test.prototype[el] = function () { |
|
|
|
this._assert(); |
|
|
|
claim[el].apply(claim, arguments); |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* Plan number of assertions |
|
|
|
* |
|
|
|