From 7bd4757bdee6c297ecd2d34f1e02fc40273dfbb4 Mon Sep 17 00:00:00 2001 From: Bryan Donovan Date: Wed, 4 Feb 2015 18:55:33 -0800 Subject: [PATCH] test case for issue #21 --- test/caching.unit.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/caching.unit.js b/test/caching.unit.js index 7180843..b627474 100644 --- a/test/caching.unit.js +++ b/test/caching.unit.js @@ -327,6 +327,30 @@ describe("caching", function() { }); }); + it("lets us make nested calls", function(done) { + function get_cached_widget(name, cb) { + cache.wrap(key, function(cache_cb) { + methods.get_widget(name, cache_cb); + }, cb); + } + + get_cached_widget(name, function(err, widget) { + check_err(err); + assert.equal(widget.name, name); + + get_cached_widget(name, function(err, widget) { + check_err(err); + assert.equal(widget.name, name); + + get_cached_widget(name, function(err, widget) { + check_err(err); + assert.equal(widget.name, name); + done(); + }); + }); + }); + }); + it("expires cached result after ttl seconds", function(done) { cache.wrap(key, function(cb) { methods.get_widget(name, cb);