auto-release-sinon
Advanced tools
Comparing version 1.0.2 to 1.0.3
function keys(obj) { | ||
// non-itterables will throw here, but checking | ||
// typeof === "object" skips things like functions | ||
try { return Object.keys(obj); } | ||
catch (e) { return []; } | ||
} | ||
function own(obj, fn) { | ||
var keys; | ||
try { keys = Object.keys(obj); } catch (e) {} // non-itterables will throw here | ||
(keys || []).forEach(function (k) { | ||
keys(obj).forEach(function (k) { | ||
fn(obj[k], k, obj); | ||
@@ -10,21 +15,24 @@ }); | ||
module.exports = function hook(sinon, afterEach) { | ||
var toWrap = { | ||
stub: null, | ||
spy: null, | ||
useFakeTimers: function (clock) { | ||
// timeouts are indexed by their id in an array, | ||
// the holes make the .length property "wrong" | ||
clock.timeoutCount = function () { | ||
return clock.timeoutList().length; | ||
}; | ||
var toRestore = []; | ||
var toWrap = { | ||
stub: null, | ||
spy: null, | ||
useFakeTimers: function (clock) { | ||
// timeouts are indexed by their id in an array, | ||
// the holes make the .length property "wrong" | ||
clock.timeoutCount = function () { | ||
return clock.timeoutList().length; | ||
}; | ||
clock.timeoutList = function () { | ||
return clock.timeouts ? clock.timeouts.filter(Boolean) : []; | ||
}; | ||
} | ||
}; | ||
clock.timeoutList = function () { | ||
return clock.timeouts ? clock.timeouts.filter(Boolean) : []; | ||
}; | ||
} | ||
}; | ||
function setupAutoRelease(actualSinon, afterEach) { | ||
var sinon = module.exports = Object.create(actualSinon); | ||
sinon.setupAutoRelease = setupAutoRelease; | ||
var toRestore = []; | ||
own(toWrap, function (modify, method) { | ||
@@ -56,2 +64,6 @@ var orig = sinon[method]; | ||
return sinon; | ||
}; | ||
} | ||
module.exports = { | ||
setupAutoRelease: setupAutoRelease | ||
}; |
{ | ||
"name": "auto-release-sinon", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Basic sinon wrapper that automatically releases it's stubs, works with mocha's BDD interface", | ||
@@ -5,0 +5,0 @@ "main": "autoReleaseSinon.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3181
72
5