From 44b31ae761990fe61d670d32a97c200a798c3ed3 Mon Sep 17 00:00:00 2001 From: Bryan Donovan Date: Sun, 29 Mar 2015 14:25:43 -1000 Subject: [PATCH] better test for parallel requests to slow function --- test/multi_caching.unit.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/multi_caching.unit.js b/test/multi_caching.unit.js index 5c425fa..cec3550 100644 --- a/test/multi_caching.unit.js +++ b/test/multi_caching.unit.js @@ -668,9 +668,20 @@ describe("multiCaching", function() { beforeEach(function() { multiCache = multiCaching([memoryCache, memoryCache3]); + var firstTimeout = 110; + var firstTimeoutUsed = false; + + function getTimeout() { + if (firstTimeoutUsed) { + support.random.number(100); + } else { + firstTimeoutUsed = true; + return firstTimeout; + } + } construct = sinon.spy(function(val, cb) { - var timeout = support.random.number(100); + var timeout = getTimeout(); setTimeout(function() { cb(null, 'value'); }, timeout);