diff options
author | Ryan Graham <r.m.graham@gmail.com> | 2013-11-23 22:20:23 -0800 |
---|---|---|
committer | Ryan Graham <r.m.graham@gmail.com> | 2013-11-23 22:33:26 -0800 |
commit | f81ef1994f8093c3ed4445bacc02c8975312f9b3 (patch) | |
tree | 8fd50584c746c348f87a103486c66dad0e17c4f8 | |
parent | be4e7ef193e68e1e78fa95c0b2922a38d24485bb (diff) | |
download | async-f81ef1994f8093c3ed4445bacc02c8975312f9b3.tar.gz |
Refactor unmemoize test to use async example
Uses async.setImmediate to make example async
-rwxr-xr-x | test/test-async.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/test-async.js b/test/test-async.js index 17e6fc5..e2690f2 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -2265,24 +2265,24 @@ exports['unmemoize'] = function(test) { var fn = function (arg1, arg2, callback) { call_order.push(['fn', arg1, arg2]); - callback(null, arg1 + arg2); + async.setImmediate(function () { + callback(null, arg1 + arg2); + }); }; var fn2 = async.memoize(fn); var fn3 = async.unmemoize(fn2); fn3(1, 2, function (err, result) { test.equal(result, 3); + fn3(1, 2, function (err, result) { + test.equal(result, 3); + fn3(2, 2, function (err, result) { + test.equal(result, 4); + test.same(call_order, [['fn',1,2], ['fn',1,2], ['fn',2,2]]); + test.done(); + }); + }); }); - fn3(1, 2, function (err, result) { - test.equal(result, 3); - }); - fn3(2, 2, function (err, result) { - test.equal(result, 4); - }); - - test.same(call_order, [['fn',1,2], ['fn',1,2], ['fn',2,2]]); - - test.done(); } exports['unmemoize a not memoized function'] = function(test) { |