Socket
Socket
Sign inDemoInstall

sinon

Package Overview
Dependencies
Maintainers
4
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon - npm Package Compare versions

Comparing version 15.0.2 to 15.0.3

lib/sinon/create-stub-instance.js

3

lib/sinon/sandbox.js

@@ -14,2 +14,3 @@ "use strict";

var sinonStub = require("./stub");
var sinonCreateStubInstance = require("./create-stub-instance");
var sinonFake = require("./fake");

@@ -75,3 +76,3 @@ var valueToString = require("@sinonjs/commons").valueToString;

sandbox.createStubInstance = function createStubInstance() {
var stubbed = sinonStub.createStubInstance.apply(null, arguments);
var stubbed = sinonCreateStubInstance.apply(null, arguments);

@@ -78,0 +79,0 @@ var ownMethods = collectOwnMethods(stubbed);

@@ -17,4 +17,5 @@ "use strict";

var calledArgumentMessage = calledArgMessage;
var matcherMessage = matcher.message;
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
matcherMessage = color.red(matcher.message);
if (calledArgumentMessage) {

@@ -24,3 +25,3 @@ calledArgumentMessage = color.green(calledArgumentMessage);

}
return `${calledArgumentMessage} ${matcher.message}`;
return `${calledArgumentMessage} ${matcherMessage}`;
}

@@ -27,0 +28,0 @@

@@ -15,2 +15,3 @@ "use strict";

var isEsModule = require("./util/core/is-es-module");
var sinonType = require("./util/core/sinon-type");
var wrapMethod = require("./util/core/wrap-method");

@@ -62,2 +63,4 @@ var throwOnFalsyObject = require("./throw-on-falsy-object");

sinonType.set(proxy, "stub");
return proxy;

@@ -131,31 +134,2 @@ }

stub.createStubInstance = function (constructor, overrides) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
// eslint-disable-next-line no-empty-function
const noop = () => {};
const defaultNoOpInstance = Object.create(constructor.prototype);
walkObject((obj, prop) => (obj[prop] = noop), defaultNoOpInstance);
const stubbedObject = stub(defaultNoOpInstance);
forEach(Object.keys(overrides || {}), function (propertyName) {
if (propertyName in stubbedObject) {
var value = overrides[propertyName];
if (value && value.createStubInstance) {
stubbedObject[propertyName] = value;
} else {
stubbedObject[propertyName].returns(value);
}
} else {
throw new Error(
`Cannot stub ${propertyName}. Property does not exist!`
);
}
});
return stubbedObject;
};
function assertValidPropertyDescriptor(descriptor, property) {

@@ -162,0 +136,0 @@ if (!descriptor || !property) {

"use strict";
// eslint-disable-next-line no-empty-function
const noop = () => {};
var getPropertyDescriptor = require("./get-property-descriptor");
var extend = require("./extend");
const sinonType = require("./sinon-type");
var hasOwnProperty =

@@ -233,2 +236,7 @@ require("@sinonjs/commons").prototypes.object.hasOwnProperty;

}
if (sinonType.get(object) === "stub-instance") {
// this is simply to avoid errors after restoring if something should
// traverse the object in a cleanup phase, ref #2477
object[property] = noop;
}
}

@@ -235,0 +243,0 @@

@@ -18,3 +18,3 @@ {

],
"version": "15.0.2",
"version": "15.0.3",
"homepage": "https://sinonjs.org/",

@@ -79,3 +79,3 @@ "author": "Christian Johansen",

"@sinonjs/fake-timers": "^10.0.2",
"@sinonjs/samsam": "^7.0.1",
"@sinonjs/samsam": "^8.0.0",
"diff": "^5.1.0",

@@ -82,0 +82,0 @@ "nise": "^5.1.4",

@@ -15,4 +15,2 @@ <h1 align=center>

<a href="https://www.npmjs.com/package/sinon"><img src="https://img.shields.io/npm/v/sinon.svg?style=flat" alt="npm version"></a>
<a href="https://gitter.im/sinonjs/sinon?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/sinonjs/sinon"></a>
<a href="http://travis-ci.org/sinonjs/sinon"><img src="https://secure.travis-ci.org/sinonjs/sinon.svg?branch=master" alt="Build status"></a>
<a href="https://saucelabs.com/u/sinonjs"><img src="https://saucelabs.com/buildstatus/sinonjs" alt="Sauce Test Status"/></a>

@@ -19,0 +17,0 @@ <a href="https://codecov.io/gh/sinonjs/sinon"><img src="https://codecov.io/gh/sinonjs/sinon/branch/master/graph/badge.svg" alt="Codecov status"></a>

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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