added quick assertion helper to check for callbacks being executed

This commit is contained in:
Brian Carlson 2010-12-02 14:43:17 -06:00
parent ed2773bdf8
commit 9447b78e9f

View File

@ -82,11 +82,24 @@ assert.length = function(actual, expectedLength) {
assert.equal(actual.length, expectedLength);
};
['equal', 'length', 'empty', 'strictEqual', 'emits', 'equalBuffers', 'same', 'ok'].forEach(function(name) {
var expect = function(callback) {
var executed = false;
setTimeout(function() {
assert.ok(executed, "Expected execution never fired");
}, 1000)
return function(err, queryResult) {
executed = true;
callback.apply(this, arguments)
}
}
assert.calls = expect;
['equal', 'length', 'empty', 'strictEqual', 'emits', 'equalBuffers', 'same', 'calls', 'ok'].forEach(function(name) {
var old = assert[name];
assert[name] = function() {
test.assertCount++
old.apply(this, arguments);
return old.apply(this, arguments);
};
});