Browse Source

better test for parallel requests to slow function

feature/specify-what-to-cache
Bryan Donovan 10 years ago
parent
commit
44b31ae761
  1. 13
      test/multi_caching.unit.js

13
test/multi_caching.unit.js

@ -668,9 +668,20 @@ describe("multiCaching", function() {
beforeEach(function() { beforeEach(function() {
multiCache = multiCaching([memoryCache, memoryCache3]); 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) { construct = sinon.spy(function(val, cb) {
var timeout = support.random.number(100); var timeout = getTimeout();
setTimeout(function() { setTimeout(function() {
cb(null, 'value'); cb(null, 'value');
}, timeout); }, timeout);

Loading…
Cancel
Save