made timeout lenght of assert.calls configurable and made tests die

sooner on error
This commit is contained in:
Brian Carlson 2010-12-09 20:50:19 -06:00
parent 169c6dc3ce
commit 10a244ae4c

View File

@ -82,11 +82,11 @@ assert.length = function(actual, expectedLength) {
assert.equal(actual.length, expectedLength); assert.equal(actual.length, expectedLength);
}; };
var expect = function(callback) { var expect = function(callback, timeout) {
var executed = false; var executed = false;
var id = setTimeout(function() { var id = setTimeout(function() {
assert.ok(executed, "Expected execution of " + callback + " fired"); assert.ok(executed, "Expected execution of " + callback + " fired");
}, 1000) }, timeout || 1000)
return function(err, queryResult) { return function(err, queryResult) {
clearTimeout(id); clearTimeout(id);
@ -105,7 +105,6 @@ assert.calls = expect;
}); });
test = function(name, action) { test = function(name, action) {
try{
test.testCount ++; test.testCount ++;
var result = action(); var result = action();
if(result === false) { if(result === false) {
@ -114,10 +113,6 @@ test = function(name, action) {
}else{ }else{
process.stdout.write('.'); process.stdout.write('.');
} }
}catch(e) {
process.stdout.write('E');
test.errors.push({name: name, e: e});
}
}; };
test.assertCount = test.assertCount || 0; test.assertCount = test.assertCount || 0;