Permalink
Browse files

test.cb propagates returned value

  • Loading branch information...
1 parent 464c5b8 commit 2eaf3283afb26f663821a7d2d8519ee77c7d8ccc @5long committed Nov 14, 2010
Showing with 21 additions and 1 deletion.
  1. +1 −1 src/test.js
  2. +20 −0 test/test_cb_return.js
View
@@ -77,7 +77,7 @@ util.def(Test.prototype, {
return function() {
executed = true
self._log(true, msg)
- fn && fn.apply(this, arguments)
+ return fn && fn.apply(this, arguments)
}
}
, _clearTimeout: function() {
View
@@ -0,0 +1,20 @@
+var assert = require("assert")
+ , Test = require("../src").Test
+ , obj = {
+ method: function() {
+ return 42
+ }
+ }
+
+var t = new Test("callback should return as original", function(test) {
+ var originalMethod = obj.method
+ obj.method = test.cb(function() {
+ return originalMethod.apply(this, arguments)
+ })
+ var returned = obj.method()
+ assert.equal(returned, 42)
+})
+
+t.run(function(err) {
+ if (err) throw err
+})

0 comments on commit 2eaf328

Please sign in to comment.