Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auto-release-sinon

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-release-sinon - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.npmignore

86

autoReleaseSinon.js

@@ -1,59 +0,55 @@

var sinon = require('sinon');
var _ = require('lodash');
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;
};
function own(obj, fn) {
if (typeof obj !== 'object') return;
clock.timeoutList = function () {
return clock.timeouts ? clock.timeouts.filter(Boolean) : [];
};
}
};
Object.keys(obj).forEach(function (k) {
fn(obj[k], k, obj);
});
}
_.forOwn(toWrap, function (modify, method) {
var orig = sinon[method];
sinon[method] = function () {
var obj = orig.apply(sinon, arguments);
module.exports = function hook(sinon, afterEach) {
// after each test this list is cleared
if (obj.restore) toRestore.push(obj);
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;
};
if (typeof modify === 'function') modify(obj);
return obj;
clock.timeoutList = function () {
return clock.timeouts ? clock.timeouts.filter(Boolean) : [];
};
}
};
_.forOwn(orig, function (val, name) {
sinon[method][name] = val;
});
});
own(toWrap, function (modify, method) {
var orig = sinon[method];
sinon[method] = function () {
var obj = orig.apply(sinon, arguments);
// helper
sinon.decorateWithSpy = _.restParam(function (props) {
return function ($delegate) {
props.forEach(function (prop) {
sinon.spy($delegate, prop);
});
// after each test this list is cleared
if (obj.restore) toRestore.push(obj);
return $delegate;
};
});
if (typeof modify === 'function') modify(obj);
afterEach(function () {
if (!toRestore.length) return;
return obj;
};
_.each(toRestore, function (obj) {
obj.restore();
own(orig, function (val, name) {
sinon[method][name] = val;
});
});
toRestore = [];
});
afterEach(function () {
toRestore.splice(0).forEach(function (obj) {
obj.restore();
});
});
return sinon;
};
{
"name": "auto-release-sinon",
"version": "1.0.0",
"version": "1.0.1",
"description": "Basic sinon wrapper that automatically releases it's stubs, works with mocha's BDD interface",

@@ -24,3 +24,12 @@ "main": "autoReleaseSinon.js",

},
"homepage": "https://github.com/spalger/auto-release-sinon#readme"
"homepage": "https://github.com/spalger/auto-release-sinon#readme",
"dependencies": {},
"peerDependencies": {
"sinon": "^1.15.4"
},
"devDependencies": {
"chai": "^3.1.0",
"mocha": "^2.2.5",
"sinon": "^1.15.4"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc