From 9447b78e9fbccc68299cdd04dcd7e8e1101699a4 Mon Sep 17 00:00:00 2001 From: Brian Carlson Date: Thu, 2 Dec 2010 14:43:17 -0600 Subject: [PATCH] added quick assertion helper to check for callbacks being executed --- test/test-helper.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/test-helper.js b/test/test-helper.js index e30fd6d6..1ac91bd8 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -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); }; });