Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

54
node_modules/sinon/README.md generated vendored
View file

@ -12,8 +12,6 @@
<p 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>
<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>
<a href="#backers"><img src="https://opencollective.com/sinon/backers/badge.svg" alt="OpenCollective"></a>
@ -66,38 +64,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how you can contribute to
## Backers
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/sinon#backer)]
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/sinon#backer)]
<a href="https://opencollective.com/sinon/backer/0/website" target="_blank"><img src="https://opencollective.com/sinon/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/1/website" target="_blank"><img src="https://opencollective.com/sinon/backer/1/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/2/website" target="_blank"><img src="https://opencollective.com/sinon/backer/2/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/3/website" target="_blank"><img src="https://opencollective.com/sinon/backer/3/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/4/website" target="_blank"><img src="https://opencollective.com/sinon/backer/4/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/5/website" target="_blank"><img src="https://opencollective.com/sinon/backer/5/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/6/website" target="_blank"><img src="https://opencollective.com/sinon/backer/6/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/7/website" target="_blank"><img src="https://opencollective.com/sinon/backer/7/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/8/website" target="_blank"><img src="https://opencollective.com/sinon/backer/8/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/9/website" target="_blank"><img src="https://opencollective.com/sinon/backer/9/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/10/website" target="_blank"><img src="https://opencollective.com/sinon/backer/10/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/11/website" target="_blank"><img src="https://opencollective.com/sinon/backer/11/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/12/website" target="_blank"><img src="https://opencollective.com/sinon/backer/12/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/13/website" target="_blank"><img src="https://opencollective.com/sinon/backer/13/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/14/website" target="_blank"><img src="https://opencollective.com/sinon/backer/14/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/15/website" target="_blank"><img src="https://opencollective.com/sinon/backer/15/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/16/website" target="_blank"><img src="https://opencollective.com/sinon/backer/16/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/17/website" target="_blank"><img src="https://opencollective.com/sinon/backer/17/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/18/website" target="_blank"><img src="https://opencollective.com/sinon/backer/18/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/19/website" target="_blank"><img src="https://opencollective.com/sinon/backer/19/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/20/website" target="_blank"><img src="https://opencollective.com/sinon/backer/20/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/21/website" target="_blank"><img src="https://opencollective.com/sinon/backer/21/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/22/website" target="_blank"><img src="https://opencollective.com/sinon/backer/22/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/23/website" target="_blank"><img src="https://opencollective.com/sinon/backer/23/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/24/website" target="_blank"><img src="https://opencollective.com/sinon/backer/24/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/25/website" target="_blank"><img src="https://opencollective.com/sinon/backer/25/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/26/website" target="_blank"><img src="https://opencollective.com/sinon/backer/26/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/27/website" target="_blank"><img src="https://opencollective.com/sinon/backer/27/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/28/website" target="_blank"><img src="https://opencollective.com/sinon/backer/28/avatar.svg"></a>
<a href="https://opencollective.com/sinon/backer/29/website" target="_blank"><img src="https://opencollective.com/sinon/backer/29/avatar.svg"></a>
<a href="https://opencollective.com/sinon#backers" target="_blank"><img src="https://opencollective.com/sinon/backers.svg?width=890"></a>
## Sponsors
@ -114,25 +83,6 @@ Become a sponsor and get your logo on our README on GitHub with a link to your s
<a href="https://opencollective.com/sinon/sponsor/8/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/9/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/9/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/10/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/10/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/11/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/11/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/12/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/12/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/13/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/13/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/14/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/14/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/15/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/15/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/16/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/16/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/17/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/17/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/18/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/18/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/19/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/19/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/20/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/20/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/21/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/21/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/22/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/22/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/23/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/23/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/24/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/24/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/25/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/25/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/26/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/26/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/27/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/27/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/28/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/28/avatar.svg"></a>
<a href="https://opencollective.com/sinon/sponsor/29/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/29/avatar.svg"></a>
## Licence

22
node_modules/sinon/lib/sinon.js generated vendored
View file

@ -1,15 +1,15 @@
"use strict";
var behavior = require("./sinon/behavior");
var createSandbox = require("./sinon/create-sandbox");
var extend = require("./sinon/util/core/extend");
var fakeTimers = require("./sinon/util/fake-timers");
var nise = require("nise");
var Sandbox = require("./sinon/sandbox");
var stub = require("./sinon/stub");
var promise = require("./sinon/promise");
const behavior = require("./sinon/behavior");
const createSandbox = require("./sinon/create-sandbox");
const extend = require("./sinon/util/core/extend");
const fakeTimers = require("./sinon/util/fake-timers");
const nise = require("nise");
const Sandbox = require("./sinon/sandbox");
const stub = require("./sinon/stub");
const promise = require("./sinon/promise");
var apiMethods = {
const apiMethods = {
createSandbox: createSandbox,
assert: require("./sinon/assert"),
match: require("@sinonjs/samsam").createMatcher,
@ -41,8 +41,8 @@ var apiMethods = {
promise: promise,
};
var sandbox = new Sandbox();
const sandbox = new Sandbox();
var api = extend(sandbox, apiMethods);
const api = extend(sandbox, apiMethods);
module.exports = api;

View file

@ -1,25 +1,125 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var calledInOrder = require("@sinonjs/commons").calledInOrder;
var createMatcher = require("@sinonjs/samsam").createMatcher;
var orderByFirstCall = require("@sinonjs/commons").orderByFirstCall;
var timesInWords = require("./util/core/times-in-words");
var inspect = require("util").inspect;
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;
var globalObject = require("@sinonjs/commons").global;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const calledInOrder = require("@sinonjs/commons").calledInOrder;
const createMatcher = require("@sinonjs/samsam").createMatcher;
const orderByFirstCall = require("@sinonjs/commons").orderByFirstCall;
const timesInWords = require("./util/core/times-in-words");
const inspect = require("util").inspect;
const stringSlice = require("@sinonjs/commons").prototypes.string.slice;
const globalObject = require("@sinonjs/commons").global;
var arraySlice = arrayProto.slice;
var concat = arrayProto.concat;
var forEach = arrayProto.forEach;
var join = arrayProto.join;
var splice = arrayProto.splice;
const arraySlice = arrayProto.slice;
const concat = arrayProto.concat;
const forEach = arrayProto.forEach;
const join = arrayProto.join;
const splice = arrayProto.splice;
function createAssertObject() {
var assert;
const assert = {
failException: "AssertError",
fail: function fail(message) {
const error = new Error(message);
error.name = this.failException || assert.failException;
throw error;
},
pass: function pass() {
return;
},
callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
let expected = "";
let actual = "";
if (!calledInOrder(arguments)) {
try {
expected = join(arguments, ", ");
const calls = arraySlice(arguments);
let i = calls.length;
while (i) {
if (!calls[--i].called) {
splice(calls, i, 1);
}
}
actual = join(orderByFirstCall(calls), ", ");
} catch (e) {
// If this fails, we'll just fall back to the blank string
}
failAssertion(
this,
`expected ${expected} to be called in order but were called as ${actual}`
);
} else {
assert.pass("callOrder");
}
},
callCount: function assertCallCount(method, count) {
verifyIsStub(method);
let msg;
if (typeof count !== "number") {
msg =
`expected ${inspect(count)} to be a number ` +
`but was of type ${typeof count}`;
failAssertion(this, msg);
} else if (method.callCount !== count) {
msg =
`expected %n to be called ${timesInWords(count)} ` +
`but was called %c%C`;
failAssertion(this, method.printf(msg));
} else {
assert.pass("callCount");
}
},
expose: function expose(target, options) {
if (!target) {
throw new TypeError("target is null or undefined");
}
const o = options || {};
const prefix =
(typeof o.prefix === "undefined" && "assert") || o.prefix;
const includeFail =
typeof o.includeFail === "undefined" || Boolean(o.includeFail);
const instance = this;
forEach(Object.keys(instance), function (method) {
if (
method !== "expose" &&
(includeFail || !/^(fail)/.test(method))
) {
target[exposedName(prefix, method)] = instance[method];
}
});
return target;
},
match: function match(actual, expectation) {
const matcher = createMatcher(expectation);
if (matcher.test(actual)) {
assert.pass("match");
} else {
const formatted = [
"expected value to match",
` expected = ${inspect(expectation)}`,
` actual = ${inspect(actual)}`,
];
failAssertion(this, join(formatted, "\n"));
}
},
};
function verifyIsStub() {
var args = arraySlice(arguments);
const args = arraySlice(arguments);
forEach(args, function (method) {
if (!method) {
@ -61,14 +161,14 @@ function createAssertObject() {
}
function failAssertion(object, msg) {
var obj = object || globalObject;
var failMethod = obj.fail || assert.fail;
const obj = object || globalObject;
const failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
function mirrorPropAsAssertion(name, method, message) {
var msg = message;
var meth = method;
let msg = message;
let meth = method;
if (arguments.length === 2) {
msg = method;
meth = name;
@ -77,8 +177,8 @@ function createAssertObject() {
assert[name] = function (fake) {
verifyIsStub(fake);
var args = arraySlice(arguments, 1);
var failed = false;
const args = arraySlice(arguments, 1);
let failed = false;
verifyIsValidAssertion(name, args);
@ -113,108 +213,6 @@ function createAssertObject() {
stringSlice(prop, 1);
}
assert = {
failException: "AssertError",
fail: function fail(message) {
var error = new Error(message);
error.name = this.failException || assert.failException;
throw error;
},
pass: function pass() {
return;
},
callOrder: function assertCallOrder() {
verifyIsStub.apply(null, arguments);
var expected = "";
var actual = "";
if (!calledInOrder(arguments)) {
try {
expected = join(arguments, ", ");
var calls = arraySlice(arguments);
var i = calls.length;
while (i) {
if (!calls[--i].called) {
splice(calls, i, 1);
}
}
actual = join(orderByFirstCall(calls), ", ");
} catch (e) {
// If this fails, we'll just fall back to the blank string
}
failAssertion(
this,
`expected ${expected} to be called in order but were called as ${actual}`
);
} else {
assert.pass("callOrder");
}
},
callCount: function assertCallCount(method, count) {
verifyIsStub(method);
var msg;
if (typeof count !== "number") {
msg =
`expected ${inspect(count)} to be a number ` +
`but was of type ${typeof count}`;
failAssertion(this, msg);
} else if (method.callCount !== count) {
msg =
`expected %n to be called ${timesInWords(count)} ` +
`but was called %c%C`;
failAssertion(this, method.printf(msg));
} else {
assert.pass("callCount");
}
},
expose: function expose(target, options) {
if (!target) {
throw new TypeError("target is null or undefined");
}
var o = options || {};
var prefix =
(typeof o.prefix === "undefined" && "assert") || o.prefix;
var includeFail =
typeof o.includeFail === "undefined" || Boolean(o.includeFail);
var instance = this;
forEach(Object.keys(instance), function (method) {
if (
method !== "expose" &&
(includeFail || !/^(fail)/.test(method))
) {
target[exposedName(prefix, method)] = instance[method];
}
});
return target;
},
match: function match(actual, expectation) {
var matcher = createMatcher(expectation);
if (matcher.test(actual)) {
assert.pass("match");
} else {
var formatted = [
"expected value to match",
` expected = ${inspect(expectation)}`,
` actual = ${inspect(actual)}`,
];
failAssertion(this, join(formatted, "\n"));
}
},
};
mirrorPropAsAssertion(
"called",
"expected %n to have been called at least once but was never called"

View file

@ -1,28 +1,28 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var extend = require("./util/core/extend");
var functionName = require("@sinonjs/commons").functionName;
var nextTick = require("./util/core/next-tick");
var valueToString = require("@sinonjs/commons").valueToString;
var exportAsyncBehaviors = require("./util/core/export-async-behaviors");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const extend = require("./util/core/extend");
const functionName = require("@sinonjs/commons").functionName;
const nextTick = require("./util/core/next-tick");
const valueToString = require("@sinonjs/commons").valueToString;
const exportAsyncBehaviors = require("./util/core/export-async-behaviors");
var concat = arrayProto.concat;
var join = arrayProto.join;
var reverse = arrayProto.reverse;
var slice = arrayProto.slice;
const concat = arrayProto.concat;
const join = arrayProto.join;
const reverse = arrayProto.reverse;
const slice = arrayProto.slice;
var useLeftMostCallback = -1;
var useRightMostCallback = -2;
const useLeftMostCallback = -1;
const useRightMostCallback = -2;
function getCallback(behavior, args) {
var callArgAt = behavior.callArgAt;
const callArgAt = behavior.callArgAt;
if (callArgAt >= 0) {
return args[callArgAt];
}
var argumentList;
let argumentList;
if (callArgAt === useLeftMostCallback) {
argumentList = args;
@ -32,9 +32,9 @@ function getCallback(behavior, args) {
argumentList = reverse(slice(args));
}
var callArgProp = behavior.callArgProp;
const callArgProp = behavior.callArgProp;
for (var i = 0, l = argumentList.length; i < l; ++i) {
for (let i = 0, l = argumentList.length; i < l; ++i) {
if (!callArgProp && typeof argumentList[i] === "function") {
return argumentList[i];
}
@ -53,7 +53,7 @@ function getCallback(behavior, args) {
function getCallbackError(behavior, func, args) {
if (behavior.callArgAt < 0) {
var msg;
let msg;
if (behavior.callArgProp) {
msg = `${functionName(
@ -80,8 +80,8 @@ function getCallbackError(behavior, func, args) {
function ensureArgs(name, behavior, args) {
// map function name to internal property
// callsArg => callArgAt
var property = name.replace(/sArg/, "ArgAt");
var index = behavior[property];
const property = name.replace(/sArg/, "ArgAt");
const index = behavior[property];
if (index >= args.length) {
throw new TypeError(
@ -95,7 +95,7 @@ function ensureArgs(name, behavior, args) {
function callCallback(behavior, args) {
if (typeof behavior.callArgAt === "number") {
ensureArgs("callsArg", behavior, args);
var func = getCallback(behavior, args);
const func = getCallback(behavior, args);
if (typeof func !== "function") {
throw new TypeError(getCallbackError(behavior, func, args));
@ -119,9 +119,9 @@ function callCallback(behavior, args) {
return undefined;
}
var proto = {
const proto = {
create: function create(stub) {
var behavior = extend({}, proto);
const behavior = extend({}, proto);
delete behavior.create;
delete behavior.addBehavior;
delete behavior.createBehavior;
@ -157,7 +157,7 @@ var proto = {
* Note: callCallback intentionally happens before
* everything else and cannot be moved lower
*/
var returnValue = callCallback(this, args);
const returnValue = callCallback(this, args);
if (this.exception) {
throw this.exception;
@ -187,16 +187,16 @@ var proto = {
} else if (this.reject) {
return (this.promiseLibrary || Promise).reject(this.returnValue);
} else if (this.callsThrough) {
var wrappedMethod = this.effectiveWrappedMethod();
const wrappedMethod = this.effectiveWrappedMethod();
return wrappedMethod.apply(context, args);
} else if (this.callsThroughWithNew) {
// Get the original method (assumed to be a constructor in this case)
var WrappedClass = this.effectiveWrappedMethod();
const WrappedClass = this.effectiveWrappedMethod();
// Turn the arguments object into a normal array
var argsArray = slice(args);
const argsArray = slice(args);
// Call the constructor
var F = WrappedClass.bind.apply(
const F = WrappedClass.bind.apply(
WrappedClass,
concat([null], argsArray)
);
@ -211,7 +211,7 @@ var proto = {
},
effectiveWrappedMethod: function effectiveWrappedMethod() {
for (var stubb = this.stub; stubb; stubb = stubb.parent) {
for (let stubb = this.stub; stubb; stubb = stubb.parent) {
if (stubb.wrappedMethod) {
return stubb.wrappedMethod;
}
@ -267,6 +267,6 @@ function addBehavior(stub, name, fn) {
proto.addBehavior = addBehavior;
proto.createBehavior = createBehavior;
var asyncBehaviors = exportAsyncBehaviors(proto);
const asyncBehaviors = exportAsyncBehaviors(proto);
module.exports = extend.nonEnum({}, proto, asyncBehaviors);

View file

@ -1,10 +1,10 @@
"use strict";
var walk = require("./util/core/walk");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var hasOwnProperty =
const walk = require("./util/core/walk");
const getPropertyDescriptor = require("./util/core/get-property-descriptor");
const hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var push = require("@sinonjs/commons").prototypes.array.push;
const push = require("@sinonjs/commons").prototypes.array.push;
function collectMethod(methods, object, prop, propOwner) {
if (
@ -17,7 +17,7 @@ function collectMethod(methods, object, prop, propOwner) {
// This function returns an array of all the own methods on the passed object
function collectOwnMethods(object) {
var methods = [];
const methods = [];
walk(object, collectMethod.bind(null, methods, object));

View file

@ -1,6 +1,6 @@
"use strict";
var supportsColor = require("supports-color");
const supportsColor = require("supports-color");
function colorize(str, color) {
if (supportsColor.stdout === false) {

View file

@ -1,13 +1,13 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var Sandbox = require("./sandbox");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const Sandbox = require("./sandbox");
var forEach = arrayProto.forEach;
var push = arrayProto.push;
const forEach = arrayProto.forEach;
const push = arrayProto.push;
function prepareSandboxFromConfig(config) {
var sandbox = new Sandbox();
const sandbox = new Sandbox();
if (config.useFakeServer) {
if (typeof config.useFakeServer === "object") {
@ -46,15 +46,15 @@ function createSandbox(config) {
return new Sandbox();
}
var configuredSandbox = prepareSandboxFromConfig(config);
const configuredSandbox = prepareSandboxFromConfig(config);
configuredSandbox.args = configuredSandbox.args || [];
configuredSandbox.injectedKeys = [];
configuredSandbox.injectInto = config.injectInto;
var exposed = configuredSandbox.inject({});
const exposed = configuredSandbox.inject({});
if (config.properties) {
forEach(config.properties, function (prop) {
var value =
const value =
exposed[prop] || (prop === "sandbox" && configuredSandbox);
exposeValue(configuredSandbox, config, prop, value);
});

36
node_modules/sinon/lib/sinon/create-stub-instance.js generated vendored Normal file
View file

@ -0,0 +1,36 @@
"use strict";
const stub = require("./stub");
const sinonType = require("./util/core/sinon-type");
const forEach = require("@sinonjs/commons").prototypes.array.forEach;
function isStub(value) {
return sinonType.get(value) === "stub";
}
module.exports = function createStubInstance(constructor, overrides) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
const stubInstance = Object.create(constructor.prototype);
sinonType.set(stubInstance, "stub-instance");
const stubbedObject = stub(stubInstance);
forEach(Object.keys(overrides || {}), function (propertyName) {
if (propertyName in stubbedObject) {
const value = overrides[propertyName];
if (isStub(value)) {
stubbedObject[propertyName] = value;
} else {
stubbedObject[propertyName].returns(value);
}
} else {
throw new Error(
`Cannot stub ${propertyName}. Property does not exist!`
);
}
});
return stubbedObject;
};

View file

@ -1,21 +1,21 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var isPropertyConfigurable = require("./util/core/is-property-configurable");
var exportAsyncBehaviors = require("./util/core/export-async-behaviors");
var extend = require("./util/core/extend");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const isPropertyConfigurable = require("./util/core/is-property-configurable");
const exportAsyncBehaviors = require("./util/core/export-async-behaviors");
const extend = require("./util/core/extend");
var slice = arrayProto.slice;
const slice = arrayProto.slice;
var useLeftMostCallback = -1;
var useRightMostCallback = -2;
const useLeftMostCallback = -1;
const useRightMostCallback = -2;
function throwsException(fake, error, message) {
if (typeof error === "function") {
fake.exceptionCreator = error;
} else if (typeof error === "string") {
fake.exceptionCreator = function () {
var newException = new Error(message || "");
const newException = new Error(message || "");
newException.name = error;
return newException;
};
@ -28,9 +28,11 @@ function throwsException(fake, error, message) {
}
}
var defaultBehaviors = {
const defaultBehaviors = {
callsFake: function callsFake(fake, fn) {
fake.fakeFn = fn;
fake.exception = undefined;
fake.exceptionCreator = undefined;
},
callsArg: function callsArg(fake, index) {
@ -190,7 +192,7 @@ var defaultBehaviors = {
},
rejects: function rejects(fake, error, message) {
var reason;
let reason;
if (typeof error === "string") {
reason = new Error(message || "");
reason.name = error;
@ -231,7 +233,7 @@ var defaultBehaviors = {
},
get: function get(fake, getterFunction) {
var rootStub = fake.stub || fake;
const rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
get: getterFunction,
@ -245,7 +247,7 @@ var defaultBehaviors = {
},
set: function set(fake, setterFunction) {
var rootStub = fake.stub || fake;
const rootStub = fake.stub || fake;
Object.defineProperty(
rootStub.rootObj,
@ -264,7 +266,7 @@ var defaultBehaviors = {
},
value: function value(fake, newVal) {
var rootStub = fake.stub || fake;
const rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
value: newVal,
@ -279,6 +281,6 @@ var defaultBehaviors = {
},
};
var asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);
const asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);
module.exports = extend({}, defaultBehaviors, asyncBehaviors);

30
node_modules/sinon/lib/sinon/fake.js generated vendored
View file

@ -1,11 +1,11 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var createProxy = require("./proxy");
var nextTick = require("./util/core/next-tick");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const createProxy = require("./proxy");
const nextTick = require("./util/core/next-tick");
var slice = arrayProto.slice;
var promiseLib = Promise;
const slice = arrayProto.slice;
let promiseLib = Promise;
module.exports = fake;
@ -187,11 +187,11 @@ fake.usingPromise = function usingPromise(promiseLibrary) {
* @returns {Function}
*/
fake.yields = function yields() {
var values = slice(arguments);
const values = slice(arguments);
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
var callback = arguments[arguments.length - 1];
const callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
@ -223,11 +223,11 @@ fake.yields = function yields() {
* @returns {Function}
*/
fake.yieldsAsync = function yieldsAsync() {
var values = slice(arguments);
const values = slice(arguments);
// eslint-disable-next-line jsdoc/require-jsdoc
function f() {
var callback = arguments[arguments.length - 1];
const callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
@ -239,7 +239,7 @@ fake.yieldsAsync = function yieldsAsync() {
return wrapFunc(f);
};
var uuid = 0;
let uuid = 0;
/**
* Creates a proxy (sinon concept) from the passed function.
*
@ -248,25 +248,25 @@ var uuid = 0;
* @returns {Function}
*/
function wrapFunc(f) {
var proxy;
var fakeInstance = function () {
var firstArg, lastArg;
const fakeInstance = function () {
let firstArg, lastArg;
if (arguments.length > 0) {
firstArg = arguments[0];
lastArg = arguments[arguments.length - 1];
}
var callback =
const callback =
lastArg && typeof lastArg === "function" ? lastArg : undefined;
/* eslint-disable no-use-before-define */
proxy.firstArg = firstArg;
proxy.lastArg = lastArg;
proxy.callback = callback;
return f && f.apply(this, arguments);
};
proxy = createProxy(fakeInstance, f || fakeInstance);
const proxy = createProxy(fakeInstance, f || fakeInstance);
proxy.displayName = "fake";
proxy.id = `fake#${uuid++}`;

View file

@ -1,21 +1,21 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var proxyInvoke = require("./proxy-invoke");
var proxyCallToString = require("./proxy-call").toString;
var timesInWords = require("./util/core/times-in-words");
var extend = require("./util/core/extend");
var match = require("@sinonjs/samsam").createMatcher;
var stub = require("./stub");
var assert = require("./assert");
var deepEqual = require("@sinonjs/samsam").deepEqual;
var inspect = require("util").inspect;
var valueToString = require("@sinonjs/commons").valueToString;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const proxyInvoke = require("./proxy-invoke");
const proxyCallToString = require("./proxy-call").toString;
const timesInWords = require("./util/core/times-in-words");
const extend = require("./util/core/extend");
const match = require("@sinonjs/samsam").createMatcher;
const stub = require("./stub");
const assert = require("./assert");
const deepEqual = require("@sinonjs/samsam").deepEqual;
const inspect = require("util").inspect;
const valueToString = require("@sinonjs/commons").valueToString;
var every = arrayProto.every;
var forEach = arrayProto.forEach;
var push = arrayProto.push;
var slice = arrayProto.slice;
const every = arrayProto.every;
const forEach = arrayProto.forEach;
const push = arrayProto.push;
const slice = arrayProto.slice;
function callCountInWords(callCount) {
if (callCount === 0) {
@ -26,11 +26,11 @@ function callCountInWords(callCount) {
}
function expectedCallCountInWords(expectation) {
var min = expectation.minCalls;
var max = expectation.maxCalls;
const min = expectation.minCalls;
const max = expectation.maxCalls;
if (typeof min === "number" && typeof max === "number") {
var str = timesInWords(min);
let str = timesInWords(min);
if (min !== max) {
str = `at least ${str} and at most ${timesInWords(max)}`;
@ -47,7 +47,7 @@ function expectedCallCountInWords(expectation) {
}
function receivedMinCalls(expectation) {
var hasMinLimit = typeof expectation.minCalls === "number";
const hasMinLimit = typeof expectation.minCalls === "number";
return !hasMinLimit || expectation.callCount >= expectation.minCalls;
}
@ -60,17 +60,17 @@ function receivedMaxCalls(expectation) {
}
function verifyMatcher(possibleMatcher, arg) {
var isMatcher = match.isMatcher(possibleMatcher);
const isMatcher = match.isMatcher(possibleMatcher);
return (isMatcher && possibleMatcher.test(arg)) || true;
}
var mockExpectation = {
const mockExpectation = {
minCalls: 1,
maxCalls: 1,
create: function create(methodName) {
var expectation = extend.nonEnum(stub(), mockExpectation);
const expectation = extend.nonEnum(stub(), mockExpectation);
delete expectation.create;
expectation.method = methodName;
@ -143,7 +143,7 @@ var mockExpectation = {
},
verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
var expectedArguments = this.expectedArguments;
const expectedArguments = this.expectedArguments;
if (receivedMaxCalls(this)) {
this.failed = true;
@ -215,7 +215,7 @@ var mockExpectation = {
},
allowsCall: function allowsCall(thisValue, args) {
var expectedArguments = this.expectedArguments;
const expectedArguments = this.expectedArguments;
if (this.met() && receivedMaxCalls(this)) {
return false;
@ -230,7 +230,7 @@ var mockExpectation = {
}
// eslint-disable-next-line no-underscore-dangle
var _args = args || [];
const _args = args || [];
if (_args.length < expectedArguments.length) {
return false;
@ -273,18 +273,18 @@ var mockExpectation = {
},
toString: function () {
var args = slice(this.expectedArguments || []);
const args = slice(this.expectedArguments || []);
if (!this.expectsExactArgCount) {
push(args, "[...]");
}
var callStr = proxyCallToString.call({
const callStr = proxyCallToString.call({
proxy: this.method || "anonymous mock expectation",
args: args,
});
var message = `${callStr.replace(
const message = `${callStr.replace(
", [...",
"[, ..."
)} ${expectedCallCountInWords(this)}`;
@ -311,7 +311,7 @@ var mockExpectation = {
},
fail: function fail(message) {
var exception = new Error(message);
const exception = new Error(message);
exception.name = "ExpectationError";
throw exception;

64
node_modules/sinon/lib/sinon/mock.js generated vendored
View file

@ -1,21 +1,21 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var mockExpectation = require("./mock-expectation");
var proxyCallToString = require("./proxy-call").toString;
var extend = require("./util/core/extend");
var deepEqual = require("@sinonjs/samsam").deepEqual;
var wrapMethod = require("./util/core/wrap-method");
var usePromiseLibrary = require("./util/core/use-promise-library");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const mockExpectation = require("./mock-expectation");
const proxyCallToString = require("./proxy-call").toString;
const extend = require("./util/core/extend");
const deepEqual = require("@sinonjs/samsam").deepEqual;
const wrapMethod = require("./util/core/wrap-method");
const usePromiseLibrary = require("./util/core/use-promise-library");
var concat = arrayProto.concat;
var filter = arrayProto.filter;
var forEach = arrayProto.forEach;
var every = arrayProto.every;
var join = arrayProto.join;
var push = arrayProto.push;
var slice = arrayProto.slice;
var unshift = arrayProto.unshift;
const concat = arrayProto.concat;
const filter = arrayProto.filter;
const forEach = arrayProto.forEach;
const every = arrayProto.every;
const join = arrayProto.join;
const push = arrayProto.push;
const slice = arrayProto.slice;
const unshift = arrayProto.unshift;
function mock(object) {
if (!object || typeof object === "string") {
@ -26,7 +26,7 @@ function mock(object) {
}
function each(collection, callback) {
var col = collection || [];
const col = collection || [];
forEach(col, callback);
}
@ -47,7 +47,7 @@ extend(mock, {
throw new TypeError("object is null");
}
var mockObject = extend.nonEnum({}, mock, { object: object });
const mockObject = extend.nonEnum({}, mock, { object: object });
delete mockObject.create;
return mockObject;
@ -66,7 +66,7 @@ extend(mock, {
if (!this.expectations[method]) {
this.expectations[method] = [];
var mockObject = this;
const mockObject = this;
wrapMethod(this.object, method, function () {
return mockObject.invokeMethod(method, this, arguments);
@ -75,7 +75,7 @@ extend(mock, {
push(this.proxies, method);
}
var expectation = mockExpectation.create(method);
const expectation = mockExpectation.create(method);
expectation.wrappedMethod = this.object[method].wrappedMethod;
push(this.expectations[method], expectation);
usePromiseLibrary(this.promiseLibrary, expectation);
@ -84,7 +84,7 @@ extend(mock, {
},
restore: function restore() {
var object = this.object;
const object = this.object;
each(this.proxies, function (proxy) {
if (typeof object[proxy].restore === "function") {
@ -94,9 +94,9 @@ extend(mock, {
},
verify: function verify() {
var expectations = this.expectations || {};
var messages = this.failures ? slice(this.failures) : [];
var met = [];
const expectations = this.expectations || {};
const messages = this.failures ? slice(this.failures) : [];
const met = [];
each(this.proxies, function (proxy) {
each(expectations[proxy], function (expectation) {
@ -128,17 +128,17 @@ extend(mock, {
invokeMethod: function invokeMethod(method, thisValue, args) {
/* if we cannot find any matching files we will explicitly call mockExpection#fail with error messages */
/* eslint consistent-return: "off" */
var expectations =
const expectations =
this.expectations && this.expectations[method]
? this.expectations[method]
: [];
var currentArgs = args || [];
var available;
const currentArgs = args || [];
let available;
var expectationsWithMatchingArgs = filter(
const expectationsWithMatchingArgs = filter(
expectations,
function (expectation) {
var expectedArgs = expectation.expectedArguments || [];
const expectedArgs = expectation.expectedArguments || [];
return arrayEquals(
expectedArgs,
@ -148,7 +148,7 @@ extend(mock, {
}
);
var expectationsToApply = filter(
const expectationsToApply = filter(
expectationsWithMatchingArgs,
function (expectation) {
return (
@ -162,8 +162,8 @@ extend(mock, {
return expectationsToApply[0].apply(thisValue, args);
}
var messages = [];
var exhausted = 0;
const messages = [];
let exhausted = 0;
forEach(expectationsWithMatchingArgs, function (expectation) {
if (expectation.allowsCall(thisValue, args)) {
@ -189,7 +189,7 @@ extend(mock, {
})}`
);
var err = new Error();
const err = new Error();
if (!err.stack) {
// PhantomJS does not serialize the stack trace until the error has been thrown
try {

View file

@ -1,11 +1,11 @@
"use strict";
var fake = require("./fake");
var isRestorable = require("./util/core/is-restorable");
const fake = require("./fake");
const isRestorable = require("./util/core/is-restorable");
var STATUS_PENDING = "pending";
var STATUS_RESOLVED = "resolved";
var STATUS_REJECTED = "rejected";
const STATUS_PENDING = "pending";
const STATUS_RESOLVED = "resolved";
const STATUS_REJECTED = "rejected";
/**
* Returns a fake for a given function or undefined. If no function is given, a
@ -34,8 +34,8 @@ function getFakeExecutor(executor) {
* @returns {Promise}
*/
function promise(executor) {
var fakeExecutor = getFakeExecutor(executor);
var sinonPromise = new Promise(fakeExecutor);
const fakeExecutor = getFakeExecutor(executor);
const sinonPromise = new Promise(fakeExecutor);
sinonPromise.status = STATUS_PENDING;
sinonPromise

View file

@ -1,6 +1,6 @@
"use strict";
var push = require("@sinonjs/commons").prototypes.array.push;
const push = require("@sinonjs/commons").prototypes.array.push;
exports.incrementCallCount = function incrementCallCount(proxy) {
proxy.called = true;
@ -39,13 +39,13 @@ exports.delegateToCalls = function delegateToCalls(
return false;
}
var currentCall;
var matches = 0;
var returnValues = [];
let currentCall;
let matches = 0;
const returnValues = [];
for (var i = 0, l = this.callCount; i < l; i += 1) {
for (let i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
var returnValue = currentCall[actual || method].apply(
const returnValue = currentCall[actual || method].apply(
currentCall,
arguments
);

View file

@ -1,18 +1,18 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var match = require("@sinonjs/samsam").createMatcher;
var deepEqual = require("@sinonjs/samsam").deepEqual;
var functionName = require("@sinonjs/commons").functionName;
var inspect = require("util").inspect;
var valueToString = require("@sinonjs/commons").valueToString;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const match = require("@sinonjs/samsam").createMatcher;
const deepEqual = require("@sinonjs/samsam").deepEqual;
const functionName = require("@sinonjs/commons").functionName;
const inspect = require("util").inspect;
const valueToString = require("@sinonjs/commons").valueToString;
var concat = arrayProto.concat;
var filter = arrayProto.filter;
var join = arrayProto.join;
var map = arrayProto.map;
var reduce = arrayProto.reduce;
var slice = arrayProto.slice;
const concat = arrayProto.concat;
const filter = arrayProto.filter;
const join = arrayProto.join;
const map = arrayProto.map;
const reduce = arrayProto.reduce;
const slice = arrayProto.slice;
/**
* @param proxy
@ -20,14 +20,14 @@ var slice = arrayProto.slice;
* @param args
*/
function throwYieldError(proxy, text, args) {
var msg = functionName(proxy) + text;
let msg = functionName(proxy) + text;
if (args.length) {
msg += ` Received [${join(slice(args), ", ")}]`;
}
throw new Error(msg);
}
var callProto = {
const callProto = {
calledOn: function calledOn(thisValue) {
if (match.isMatcher(thisValue)) {
return thisValue.test(this.thisValue);
@ -36,8 +36,8 @@ var callProto = {
},
calledWith: function calledWith() {
var self = this;
var calledWithArgs = slice(arguments);
const self = this;
const calledWithArgs = slice(arguments);
if (calledWithArgs.length > self.args.length) {
return false;
@ -53,8 +53,8 @@ var callProto = {
},
calledWithMatch: function calledWithMatch() {
var self = this;
var calledWithMatchArgs = slice(arguments);
const self = this;
const calledWithMatchArgs = slice(arguments);
if (calledWithMatchArgs.length > self.args.length) {
return false;
@ -63,7 +63,7 @@ var callProto = {
return reduce(
calledWithMatchArgs,
function (prev, expectation, i) {
var actual = self.args[i];
const actual = self.args[i];
return prev && match(expectation).test(actual);
},
@ -137,7 +137,7 @@ var callProto = {
callArgOnWith: function (pos, thisValue) {
this.ensureArgIsAFunction(pos);
var args = slice(arguments, 2);
const args = slice(arguments, 2);
return this.args[pos].apply(thisValue, args);
},
@ -156,8 +156,8 @@ var callProto = {
},
yieldOn: function (thisValue) {
var args = slice(this.args);
var yieldFn = filter(args, function (arg) {
const args = slice(this.args);
const yieldFn = filter(args, function (arg) {
return typeof arg === "function";
})[0];
@ -180,11 +180,11 @@ var callProto = {
},
yieldToOn: function (prop, thisValue) {
var args = slice(this.args);
var yieldArg = filter(args, function (arg) {
const args = slice(this.args);
const yieldArg = filter(args, function (arg) {
return arg && typeof arg[prop] === "function";
})[0];
var yieldFn = yieldArg && yieldArg[prop];
const yieldFn = yieldArg && yieldArg[prop];
if (!yieldFn) {
throwYieldError(
@ -200,14 +200,12 @@ var callProto = {
},
toString: function () {
var callStr = this.proxy ? `${String(this.proxy)}(` : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = map(this.args, function (arg) {
let callStr = this.proxy ? `${String(this.proxy)}(` : "";
const formattedArgs = map(this.args, function (arg) {
return inspect(arg);
});
@ -277,15 +275,15 @@ function createProxyCall(
throw new TypeError("Call id is not a number");
}
var firstArg, lastArg;
let firstArg, lastArg;
if (args.length > 0) {
firstArg = args[0];
lastArg = args[args.length - 1];
}
var proxyCall = Object.create(callProto);
var callback =
const proxyCall = Object.create(callProto);
const callback =
lastArg && typeof lastArg === "function" ? lastArg : undefined;
proxyCall.proxy = proxy;

View file

@ -1,20 +1,20 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var proxyCallUtil = require("./proxy-call-util");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const proxyCallUtil = require("./proxy-call-util");
var push = arrayProto.push;
var forEach = arrayProto.forEach;
var concat = arrayProto.concat;
var ErrorConstructor = Error.prototype.constructor;
var bind = Function.prototype.bind;
const push = arrayProto.push;
const forEach = arrayProto.forEach;
const concat = arrayProto.concat;
const ErrorConstructor = Error.prototype.constructor;
const bind = Function.prototype.bind;
var callId = 0;
let callId = 0;
module.exports = function invoke(func, thisValue, args) {
var matchings = this.matchingFakes(args);
var currentCallId = callId++;
var exception, returnValue;
const matchings = this.matchingFakes(args);
const currentCallId = callId++;
let exception, returnValue;
proxyCallUtil.incrementCallCount(this);
push(this.thisValues, thisValue);
@ -34,7 +34,7 @@ module.exports = function invoke(func, thisValue, args) {
try {
this.invoking = true;
var thisCall = this.getCall(this.callCount - 1);
const thisCall = this.getCall(this.callCount - 1);
if (thisCall.calledWithNew()) {
// Call through with `new`
@ -43,7 +43,10 @@ module.exports = function invoke(func, thisValue, args) {
concat([thisValue], args)
))();
if (typeof returnValue !== "object") {
if (
typeof returnValue !== "object" &&
typeof returnValue !== "function"
) {
returnValue = thisValue;
}
} else {
@ -62,7 +65,7 @@ module.exports = function invoke(func, thisValue, args) {
push(matching.returnValues, returnValue);
});
var err = new ErrorConstructor();
const err = new ErrorConstructor();
// 1. Please do not get stack at this point. It may be so very slow, and not actually used
// 2. PhantomJS does not serialize the stack trace until the error has been thrown:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack

View file

@ -1,26 +1,26 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var extend = require("./util/core/extend");
var functionToString = require("./util/core/function-to-string");
var proxyCall = require("./proxy-call");
var proxyCallUtil = require("./proxy-call-util");
var proxyInvoke = require("./proxy-invoke");
var inspect = require("util").inspect;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const extend = require("./util/core/extend");
const functionToString = require("./util/core/function-to-string");
const proxyCall = require("./proxy-call");
const proxyCallUtil = require("./proxy-call-util");
const proxyInvoke = require("./proxy-invoke");
const inspect = require("util").inspect;
var push = arrayProto.push;
var forEach = arrayProto.forEach;
var slice = arrayProto.slice;
const push = arrayProto.push;
const forEach = arrayProto.forEach;
const slice = arrayProto.slice;
var emptyFakes = Object.freeze([]);
const emptyFakes = Object.freeze([]);
// Public API
var proxyApi = {
const proxyApi = {
toString: functionToString,
named: function named(name) {
this.displayName = name;
var nameDescriptor = Object.getOwnPropertyDescriptor(this, "name");
const nameDescriptor = Object.getOwnPropertyDescriptor(this, "name");
if (nameDescriptor && nameDescriptor.configurable) {
// IE 11 functions don't have a name.
// Safari 9 has names that are not configurable.
@ -41,7 +41,7 @@ var proxyApi = {
},
getCall: function getCall(index) {
var i = index;
let i = index;
if (i < 0) {
// Negative indices means counting backwards from the last call
i += this.callCount;
@ -62,8 +62,8 @@ var proxyApi = {
},
getCalls: function () {
var calls = [];
var i;
const calls = [];
let i;
for (i = 0; i < this.callCount; i++) {
push(calls, this.getCall(i));
@ -116,9 +116,9 @@ var proxyApi = {
formatters: require("./spy-formatters"),
printf: function (format) {
var spyInstance = this;
var args = slice(arguments, 1);
var formatter;
const spyInstance = this;
const args = slice(arguments, 1);
let formatter;
return (format || "").replace(/%(.)/g, function (match, specifier) {
formatter = proxyApi.formatters[specifier];
@ -135,7 +135,7 @@ var proxyApi = {
resetHistory: function () {
if (this.invoking) {
var err = new Error(
const err = new Error(
"Cannot reset Sinon function while invoking it. " +
"Move the call to .resetHistory outside of the callback."
);
@ -172,7 +172,7 @@ var proxyApi = {
},
};
var delegateToCalls = proxyCallUtil.delegateToCalls;
const delegateToCalls = proxyCallUtil.delegateToCalls;
delegateToCalls(proxyApi, "calledOn", true);
delegateToCalls(proxyApi, "alwaysCalledOn", false, "calledOn");
delegateToCalls(proxyApi, "calledWith", true);
@ -241,7 +241,7 @@ delegateToCalls(proxyApi, "calledWithNew", true);
delegateToCalls(proxyApi, "alwaysCalledWithNew", false, "calledWithNew");
function createProxy(func, originalFunc) {
var proxy = wrapFunction(func, originalFunc);
const proxy = wrapFunction(func, originalFunc);
// Inherit function properties:
extend(proxy, func);
@ -254,8 +254,8 @@ function createProxy(func, originalFunc) {
}
function wrapFunction(func, originalFunc) {
var arity = originalFunc.length;
var p;
const arity = originalFunc.length;
let p;
// Do not change this to use an eval. Projects that depend on sinon block the use of eval.
// ref: https://github.com/sinonjs/sinon/issues/710
switch (arity) {
@ -332,7 +332,10 @@ function wrapFunction(func, originalFunc) {
break;
/*eslint-enable*/
}
var nameDescriptor = Object.getOwnPropertyDescriptor(originalFunc, "name");
const nameDescriptor = Object.getOwnPropertyDescriptor(
originalFunc,
"name"
);
if (nameDescriptor && nameDescriptor.configurable) {
// IE 11 functions don't have a name.
// Safari 9 has names that are not configurable.

View file

@ -1,6 +1,6 @@
"use strict";
var walkObject = require("./util/core/walk-object");
const walkObject = require("./util/core/walk-object");
function filter(object, property) {
return object[property].restore && object[property].restore.sinon;

View file

@ -1,31 +1,32 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var logger = require("@sinonjs/commons").deprecated;
var collectOwnMethods = require("./collect-own-methods");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var isPropertyConfigurable = require("./util/core/is-property-configurable");
var match = require("@sinonjs/samsam").createMatcher;
var sinonAssert = require("./assert");
var sinonClock = require("./util/fake-timers");
var sinonMock = require("./mock");
var sinonSpy = require("./spy");
var sinonStub = require("./stub");
var sinonFake = require("./fake");
var valueToString = require("@sinonjs/commons").valueToString;
var fakeServer = require("nise").fakeServer;
var fakeXhr = require("nise").fakeXhr;
var usePromiseLibrary = require("./util/core/use-promise-library");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const logger = require("@sinonjs/commons").deprecated;
const collectOwnMethods = require("./collect-own-methods");
const getPropertyDescriptor = require("./util/core/get-property-descriptor");
const isPropertyConfigurable = require("./util/core/is-property-configurable");
const match = require("@sinonjs/samsam").createMatcher;
const sinonAssert = require("./assert");
const sinonClock = require("./util/fake-timers");
const sinonMock = require("./mock");
const sinonSpy = require("./spy");
const sinonStub = require("./stub");
const sinonCreateStubInstance = require("./create-stub-instance");
const sinonFake = require("./fake");
const valueToString = require("@sinonjs/commons").valueToString;
const fakeServer = require("nise").fakeServer;
const fakeXhr = require("nise").fakeXhr;
const usePromiseLibrary = require("./util/core/use-promise-library");
var DEFAULT_LEAK_THRESHOLD = 10000;
const DEFAULT_LEAK_THRESHOLD = 10000;
var filter = arrayProto.filter;
var forEach = arrayProto.forEach;
var push = arrayProto.push;
var reverse = arrayProto.reverse;
const filter = arrayProto.filter;
const forEach = arrayProto.forEach;
const push = arrayProto.push;
const reverse = arrayProto.reverse;
function applyOnEach(fakes, method) {
var matchingFakes = filter(fakes, function (fake) {
const matchingFakes = filter(fakes, function (fake) {
return typeof fake[method] === "function";
});
@ -35,12 +36,12 @@ function applyOnEach(fakes, method) {
}
function Sandbox() {
var sandbox = this;
var fakeRestorers = [];
var promiseLib;
const sandbox = this;
let fakeRestorers = [];
let promiseLib;
var collection = [];
var loggedLeakWarning = false;
let collection = [];
let loggedLeakWarning = false;
sandbox.leakThreshold = DEFAULT_LEAK_THRESHOLD;
function addToCollection(object) {
@ -71,9 +72,9 @@ function Sandbox() {
};
sandbox.createStubInstance = function createStubInstance() {
var stubbed = sinonStub.createStubInstance.apply(null, arguments);
const stubbed = sinonCreateStubInstance.apply(null, arguments);
var ownMethods = collectOwnMethods(stubbed);
const ownMethods = collectOwnMethods(stubbed);
forEach(ownMethods, function (method) {
addToCollection(method);
@ -132,7 +133,7 @@ function Sandbox() {
};
sandbox.mock = function mock() {
var m = sinonMock.apply(null, arguments);
const m = sinonMock.apply(null, arguments);
addToCollection(m);
usePromiseLibrary(promiseLib, m);
@ -151,7 +152,7 @@ function Sandbox() {
sandbox.resetHistory = function resetHistory() {
function privateResetHistory(f) {
var method = f.resetHistory || f.reset;
const method = f.resetHistory || f.reset;
if (method) {
method.call(f);
}
@ -163,7 +164,7 @@ function Sandbox() {
return;
}
var methods = [];
const methods = [];
if (fake.get) {
push(methods, fake.get);
}
@ -196,8 +197,8 @@ function Sandbox() {
};
sandbox.restoreContext = function restoreContext() {
var injectedKeys = sandbox.injectedKeys;
var injectInto = sandbox.injectInto;
let injectedKeys = sandbox.injectedKeys;
const injectInto = sandbox.injectInto;
if (!injectedKeys) {
return;
@ -211,7 +212,7 @@ function Sandbox() {
};
function getFakeRestorer(object, property) {
var descriptor = getPropertyDescriptor(object, property);
const descriptor = getPropertyDescriptor(object, property);
function restorer() {
if (descriptor.isOwn) {
@ -239,7 +240,7 @@ function Sandbox() {
}
sandbox.replace = function replace(object, property, replacement) {
var descriptor = getPropertyDescriptor(object, property);
const descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError(
@ -284,7 +285,7 @@ function Sandbox() {
property,
replacement
) {
var descriptor = getPropertyDescriptor(object, property);
const descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError(
@ -322,7 +323,7 @@ function Sandbox() {
property,
replacement
) {
var descriptor = getPropertyDescriptor(object, property);
const descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError(
@ -357,14 +358,14 @@ function Sandbox() {
};
function commonPostInitSetup(args, spy) {
var object = args[0];
var property = args[1];
const object = args[0];
const property = args[1];
var isSpyingOnEntireObject =
const isSpyingOnEntireObject =
typeof property === "undefined" && typeof object === "object";
if (isSpyingOnEntireObject) {
var ownMethods = collectOwnMethods(spy);
const ownMethods = collectOwnMethods(spy);
forEach(ownMethods, function (method) {
addToCollection(method);
@ -380,18 +381,18 @@ function Sandbox() {
}
sandbox.spy = function spy() {
var createdSpy = sinonSpy.apply(sinonSpy, arguments);
const createdSpy = sinonSpy.apply(sinonSpy, arguments);
return commonPostInitSetup(arguments, createdSpy);
};
sandbox.stub = function stub() {
var createdStub = sinonStub.apply(sinonStub, arguments);
const createdStub = sinonStub.apply(sinonStub, arguments);
return commonPostInitSetup(arguments, createdStub);
};
// eslint-disable-next-line no-unused-vars
sandbox.fake = function fake(f) {
var s = sinonFake.apply(sinonFake, arguments);
const s = sinonFake.apply(sinonFake, arguments);
addToCollection(s);
@ -399,10 +400,10 @@ function Sandbox() {
};
forEach(Object.keys(sinonFake), function (key) {
var fakeBehavior = sinonFake[key];
const fakeBehavior = sinonFake[key];
if (typeof fakeBehavior === "function") {
sandbox.fake[key] = function () {
var s = fakeBehavior.apply(fakeBehavior, arguments);
const s = fakeBehavior.apply(fakeBehavior, arguments);
addToCollection(s);
@ -412,7 +413,7 @@ function Sandbox() {
});
sandbox.useFakeTimers = function useFakeTimers(args) {
var clock = sinonClock.useFakeTimers.call(null, args);
const clock = sinonClock.useFakeTimers.call(null, args);
sandbox.clock = clock;
addToCollection(clock);
@ -425,7 +426,7 @@ function Sandbox() {
};
sandbox.verifyAndRestore = function verifyAndRestore() {
var exception;
let exception;
try {
sandbox.verify();
@ -441,7 +442,7 @@ function Sandbox() {
};
sandbox.useFakeServer = function useFakeServer() {
var proto = sandbox.serverPrototype || fakeServer;
const proto = sandbox.serverPrototype || fakeServer;
if (!proto || !proto.create) {
return null;
@ -454,7 +455,7 @@ function Sandbox() {
};
sandbox.useFakeXMLHttpRequest = function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
const xhr = fakeXhr.useFakeXMLHttpRequest();
addToCollection(xhr);
return xhr;
};

View file

@ -1,31 +1,32 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var color = require("./color");
var match = require("@sinonjs/samsam").createMatcher;
var timesInWords = require("./util/core/times-in-words");
var inspect = require("util").inspect;
var jsDiff = require("diff");
const arrayProto = require("@sinonjs/commons").prototypes.array;
const color = require("./color");
const match = require("@sinonjs/samsam").createMatcher;
const timesInWords = require("./util/core/times-in-words");
const inspect = require("util").inspect;
const jsDiff = require("diff");
var join = arrayProto.join;
var map = arrayProto.map;
var push = arrayProto.push;
var slice = arrayProto.slice;
const join = arrayProto.join;
const map = arrayProto.map;
const push = arrayProto.push;
const slice = arrayProto.slice;
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
var calledArgumentMessage = calledArgMessage;
let calledArgumentMessage = calledArgMessage;
let matcherMessage = matcher.message;
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
matcherMessage = color.red(matcher.message);
if (calledArgumentMessage) {
calledArgumentMessage = color.green(calledArgumentMessage);
}
}
return `${calledArgumentMessage} ${matcher.message}`;
return `${calledArgumentMessage} ${matcherMessage}`;
}
function colorDiffText(diff) {
var objects = map(diff, function (part) {
var text = part.value;
const objects = map(diff, function (part) {
let text = part.value;
if (part.added) {
text = color.green(text);
} else if (part.removed) {
@ -57,23 +58,23 @@ module.exports = {
},
D: function (spyInstance, args) {
var message = "";
let message = "";
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
for (let i = 0, l = spyInstance.callCount; i < l; ++i) {
// describe multiple calls
if (l > 1) {
message += `\nCall ${i + 1}:`;
}
var calledArgs = spyInstance.getCall(i).args;
var expectedArgs = slice(args);
const calledArgs = spyInstance.getCall(i).args;
const expectedArgs = slice(args);
for (
var j = 0;
let j = 0;
j < calledArgs.length || j < expectedArgs.length;
++j
) {
var calledArg = calledArgs[j];
var expectedArg = expectedArgs[j];
let calledArg = calledArgs[j];
let expectedArg = expectedArgs[j];
if (calledArg) {
calledArg = quoteStringValue(calledArg);
}
@ -84,7 +85,7 @@ module.exports = {
message += "\n";
var calledArgMessage =
const calledArgMessage =
j < calledArgs.length ? inspect(calledArg) : "";
if (match.isMatcher(expectedArg)) {
message += colorSinonMatchText(
@ -93,9 +94,9 @@ module.exports = {
calledArgMessage
);
} else {
var expectedArgMessage =
const expectedArgMessage =
j < expectedArgs.length ? inspect(expectedArg) : "";
var diff = jsDiff.diffJson(
const diff = jsDiff.diffJson(
calledArgMessage,
expectedArgMessage
);
@ -108,11 +109,11 @@ module.exports = {
},
C: function (spyInstance) {
var calls = [];
const calls = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
for (let i = 0, l = spyInstance.callCount; i < l; ++i) {
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
var stringifiedCall = ` ${spyInstance.getCall(i).toString()}`;
let stringifiedCall = ` ${spyInstance.getCall(i).toString()}`;
if (/\n/.test(calls[i - 1])) {
stringifiedCall = `\n${stringifiedCall}`;
}
@ -123,9 +124,9 @@ module.exports = {
},
t: function (spyInstance) {
var objects = [];
const objects = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
for (let i = 0, l = spyInstance.callCount; i < l; ++i) {
push(objects, inspect(spyInstance.thisValues[i]));
}

60
node_modules/sinon/lib/sinon/spy.js generated vendored
View file

@ -1,28 +1,28 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var createProxy = require("./proxy");
var extend = require("./util/core/extend");
var functionName = require("@sinonjs/commons").functionName;
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var deepEqual = require("@sinonjs/samsam").deepEqual;
var isEsModule = require("./util/core/is-es-module");
var proxyCallUtil = require("./proxy-call-util");
var walkObject = require("./util/core/walk-object");
var wrapMethod = require("./util/core/wrap-method");
var valueToString = require("@sinonjs/commons").valueToString;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const createProxy = require("./proxy");
const extend = require("./util/core/extend");
const functionName = require("@sinonjs/commons").functionName;
const getPropertyDescriptor = require("./util/core/get-property-descriptor");
const deepEqual = require("@sinonjs/samsam").deepEqual;
const isEsModule = require("./util/core/is-es-module");
const proxyCallUtil = require("./proxy-call-util");
const walkObject = require("./util/core/walk-object");
const wrapMethod = require("./util/core/wrap-method");
const valueToString = require("@sinonjs/commons").valueToString;
/* cache references to library methods so that they also can be stubbed without problems */
var forEach = arrayProto.forEach;
var pop = arrayProto.pop;
var push = arrayProto.push;
var slice = arrayProto.slice;
var filter = Array.prototype.filter;
const forEach = arrayProto.forEach;
const pop = arrayProto.pop;
const push = arrayProto.push;
const slice = arrayProto.slice;
const filter = Array.prototype.filter;
var uuid = 0;
let uuid = 0;
function matches(fake, args, strict) {
var margs = fake.matchingArguments;
const margs = fake.matchingArguments;
if (
margs.length <= args.length &&
deepEqual(slice(args, 0, margs.length), margs)
@ -33,16 +33,16 @@ function matches(fake, args, strict) {
}
// Public API
var spyApi = {
const spyApi = {
withArgs: function () {
var args = slice(arguments);
var matching = pop(this.matchingFakes(args, true));
const args = slice(arguments);
const matching = pop(this.matchingFakes(args, true));
if (matching) {
return matching;
}
var original = this;
var fake = this.instantiateFake();
const original = this;
const fake = this.instantiateFake();
fake.matchingArguments = args;
fake.parent = this;
push(this.fakes, fake);
@ -78,7 +78,7 @@ var spyApi = {
};
/* eslint-disable @sinonjs/no-prototype-methods/no-prototype-methods */
var delegateToCalls = proxyCallUtil.delegateToCalls;
const delegateToCalls = proxyCallUtil.delegateToCalls;
delegateToCalls(spyApi, "callArg", false, "callArgWith", true, function () {
throw new Error(
`${this.toString()} cannot call arg since it was not yet invoked.`
@ -131,8 +131,8 @@ delegateToCalls(
);
function createSpy(func) {
var name;
var funk = func;
let name;
let funk = func;
if (typeof funk !== "function") {
funk = function () {
@ -142,7 +142,7 @@ function createSpy(func) {
name = functionName(funk);
}
var proxy = createProxy(funk, funk);
const proxy = createProxy(funk, funk);
// Inherit spy API:
extend.nonEnum(proxy, spyApi);
@ -156,8 +156,6 @@ function createSpy(func) {
}
function spy(object, property, types) {
var descriptor, methodDesc;
if (isEsModule(object)) {
throw new TypeError("ES Modules cannot be spied");
}
@ -180,8 +178,8 @@ function spy(object, property, types) {
return wrapMethod(object, property, createSpy(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
const descriptor = {};
const methodDesc = getPropertyDescriptor(object, property);
forEach(types, function (type) {
descriptor[type] = createSpy(methodDesc[type]);

100
node_modules/sinon/lib/sinon/stub.js generated vendored
View file

@ -1,37 +1,39 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var behavior = require("./behavior");
var behaviors = require("./default-behaviors");
var createProxy = require("./proxy");
var functionName = require("@sinonjs/commons").functionName;
var hasOwnProperty =
const arrayProto = require("@sinonjs/commons").prototypes.array;
const behavior = require("./behavior");
const behaviors = require("./default-behaviors");
const createProxy = require("./proxy");
const functionName = require("@sinonjs/commons").functionName;
const hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var isNonExistentProperty = require("./util/core/is-non-existent-property");
var spy = require("./spy");
var extend = require("./util/core/extend");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var isEsModule = require("./util/core/is-es-module");
var wrapMethod = require("./util/core/wrap-method");
var throwOnFalsyObject = require("./throw-on-falsy-object");
var valueToString = require("@sinonjs/commons").valueToString;
var walkObject = require("./util/core/walk-object");
const isNonExistentProperty = require("./util/core/is-non-existent-property");
const spy = require("./spy");
const extend = require("./util/core/extend");
const getPropertyDescriptor = require("./util/core/get-property-descriptor");
const isEsModule = require("./util/core/is-es-module");
const sinonType = require("./util/core/sinon-type");
const wrapMethod = require("./util/core/wrap-method");
const throwOnFalsyObject = require("./throw-on-falsy-object");
const valueToString = require("@sinonjs/commons").valueToString;
const walkObject = require("./util/core/walk-object");
var forEach = arrayProto.forEach;
var pop = arrayProto.pop;
var slice = arrayProto.slice;
var sort = arrayProto.sort;
const forEach = arrayProto.forEach;
const pop = arrayProto.pop;
const slice = arrayProto.slice;
const sort = arrayProto.sort;
var uuid = 0;
let uuid = 0;
function createStub(originalFunc) {
var proxy;
// eslint-disable-next-line prefer-const
let proxy;
function functionStub() {
var args = slice(arguments);
var matchings = proxy.matchingFakes(args);
const args = slice(arguments);
const matchings = proxy.matchingFakes(args);
var fnStub =
const fnStub =
pop(
sort(matchings, function (a, b) {
return (
@ -48,7 +50,7 @@ function createStub(originalFunc) {
// Inherit stub API:
extend.nonEnum(proxy, stub);
var name = originalFunc ? functionName(originalFunc) : null;
const name = originalFunc ? functionName(originalFunc) : null;
extend.nonEnum(proxy, {
fakes: [],
instantiateFake: createStub,
@ -58,6 +60,8 @@ function createStub(originalFunc) {
id: `stub#${uuid++}`,
});
sinonType.set(proxy, "stub");
return proxy;
}
@ -80,16 +84,16 @@ function stub(object, property) {
);
}
var actualDescriptor = getPropertyDescriptor(object, property);
const actualDescriptor = getPropertyDescriptor(object, property);
assertValidPropertyDescriptor(actualDescriptor, property);
var isObjectOrFunction =
const isObjectOrFunction =
typeof object === "object" || typeof object === "function";
var isStubbingEntireObject =
const isStubbingEntireObject =
typeof property === "undefined" && isObjectOrFunction;
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingNonFuncProperty =
const isCreatingNewStub = !object && typeof property === "undefined";
const isStubbingNonFuncProperty =
isObjectOrFunction &&
typeof property !== "undefined" &&
(typeof actualDescriptor === "undefined" ||
@ -103,11 +107,11 @@ function stub(object, property) {
return createStub();
}
var func =
const func =
typeof actualDescriptor.value === "function"
? actualDescriptor.value
: null;
var s = createStub(func);
const s = createStub(func);
extend.nonEnum(s, {
rootObj: object,
@ -126,35 +130,11 @@ function stub(object, property) {
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}
stub.createStubInstance = function (constructor, overrides) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
var stubbedObject = stub(Object.create(constructor.prototype));
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) {
if (!descriptor || !property) {
return;
}
if (!descriptor.configurable && !descriptor.writable) {
if (descriptor.isOwn && !descriptor.configurable && !descriptor.writable) {
throw new TypeError(
`Descriptor for property ${property} is non-configurable and non-writable`
);
@ -194,14 +174,14 @@ function getDefaultBehavior(stubInstance) {
}
function getCurrentBehavior(stubInstance) {
var currentBehavior = stubInstance.behaviors[stubInstance.callCount - 1];
const currentBehavior = stubInstance.behaviors[stubInstance.callCount - 1];
return currentBehavior && currentBehavior.isPresent()
? currentBehavior
: getDefaultBehavior(stubInstance);
}
/*eslint-enable no-use-before-define*/
var proto = {
const proto = {
resetBehavior: function () {
this.defaultBehavior = null;
this.behaviors = [];
@ -245,7 +225,7 @@ var proto = {
},
withArgs: function withArgs() {
var fake = spy.withArgs.apply(this, arguments);
const fake = spy.withArgs.apply(this, arguments);
if (this.defaultBehavior && this.defaultBehavior.promiseLibrary) {
fake.defaultBehavior =
fake.defaultBehavior || behavior.create(fake);

View file

@ -1,9 +1,9 @@
"use strict";
var valueToString = require("@sinonjs/commons").valueToString;
const valueToString = require("@sinonjs/commons").valueToString;
function throwOnFalsyObject(object, property) {
if (property && !object) {
var type = object === null ? "null" : "undefined";
const type = object === null ? "null" : "undefined";
throw new Error(
`Trying to stub property '${valueToString(property)}' of ${type}`
);

View file

@ -1,7 +1,7 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var reduce = arrayProto.reduce;
const arrayProto = require("@sinonjs/commons").prototypes.array;
const reduce = arrayProto.reduce;
module.exports = function exportAsyncBehaviors(behaviorMethods) {
return reduce(
@ -10,7 +10,10 @@ module.exports = function exportAsyncBehaviors(behaviorMethods) {
// need to avoid creating another async versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
acc[`${method}Async`] = function () {
var result = behaviorMethods[method].apply(this, arguments);
const result = behaviorMethods[method].apply(
this,
arguments
);
this.callbackAsync = true;
return result;
};

View file

@ -1,15 +1,15 @@
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var hasOwnProperty =
const arrayProto = require("@sinonjs/commons").prototypes.array;
const hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var join = arrayProto.join;
var push = arrayProto.push;
const join = arrayProto.join;
const push = arrayProto.push;
// Adapted from https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
var hasDontEnumBug = (function () {
var obj = {
const hasDontEnumBug = (function () {
const obj = {
constructor: function () {
return "0";
},
@ -42,8 +42,8 @@ var hasDontEnumBug = (function () {
},
};
var result = [];
for (var prop in obj) {
const result = [];
for (const prop in obj) {
if (hasOwnProperty(obj, prop)) {
push(result, obj[prop]());
}
@ -51,8 +51,15 @@ var hasDontEnumBug = (function () {
return join(result, "") !== "0123456789";
})();
/**
*
* @param target
* @param sources
* @param doCopy
* @returns {*} target
*/
function extendCommon(target, sources, doCopy) {
var source, i, prop;
let source, i, prop;
for (i = 0; i < sources.length; i++) {
source = sources[i];
@ -77,12 +84,12 @@ function extendCommon(target, sources, doCopy) {
return target;
}
/** Public: Extend target in place with all (own) properties, except 'name' when [[writable]] is false,
/**
* Public: Extend target in place with all (own) properties, except 'name' when [[writable]] is false,
* from sources in-order. Thus, last source will override properties in previous sources.
*
* @param {object} target - The Object to extend
* @param {object[]} sources - Objects to copy properties from.
*
* @returns {object} the extended target
*/
module.exports = function extend(target, ...sources) {
@ -90,11 +97,11 @@ module.exports = function extend(target, ...sources) {
target,
sources,
function copyValue(dest, source, prop) {
var destOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
const destOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
dest,
prop
);
var sourceOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
const sourceOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
source,
prop
);
@ -130,12 +137,12 @@ module.exports = function extend(target, ...sources) {
);
};
/** Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
/**
* Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
* override properties in previous sources. Define the properties as non enumerable.
*
* @param {object} target - The Object to extend
* @param {object[]} sources - Objects to copy properties from.
*
* @returns {object} the extended target
*/
module.exports.nonEnum = function extendNonEnum(target, ...sources) {

View file

@ -1,7 +1,7 @@
"use strict";
module.exports = function toString() {
var i, prop, thisValue;
let i, prop, thisValue;
if (this.getCall && this.callCount) {
i = this.callCount;

View file

@ -1,9 +1,9 @@
"use strict";
module.exports = function getPropertyDescriptor(object, property) {
var proto = object;
var descriptor;
var isOwn = Boolean(
let proto = object;
let descriptor;
const isOwn = Boolean(
object && Object.getOwnPropertyDescriptor(object, property)
);

View file

@ -8,7 +8,6 @@
* on weird error messages.
*
* @param {object} object The object to examine
*
* @returns {boolean} true when the object is a module
*/
module.exports = function (object) {

View file

@ -1,9 +1,9 @@
"use strict";
var getPropertyDescriptor = require("./get-property-descriptor");
const getPropertyDescriptor = require("./get-property-descriptor");
function isPropertyConfigurable(obj, propName) {
var propertyDescriptor = getPropertyDescriptor(obj, propName);
const propertyDescriptor = getPropertyDescriptor(obj, propName);
return propertyDescriptor ? propertyDescriptor.configurable : true;
}

View file

@ -1,6 +1,6 @@
"use strict";
var globalObject = require("@sinonjs/commons").global;
var getNextTick = require("./get-next-tick");
const globalObject = require("@sinonjs/commons").global;
const getNextTick = require("./get-next-tick");
module.exports = getNextTick(globalObject.process, globalObject.setImmediate);

22
node_modules/sinon/lib/sinon/util/core/sinon-type.js generated vendored Normal file
View file

@ -0,0 +1,22 @@
"use strict";
const sinonTypeSymbolProperty = Symbol("SinonType");
module.exports = {
/**
* Set the type of a Sinon object to make it possible to identify it later at runtime
*
* @param {object|Function} object object/function to set the type on
* @param {string} type the named type of the object/function
*/
set(object, type) {
Object.defineProperty(object, sinonTypeSymbolProperty, {
value: type,
configurable: false,
enumerable: false,
});
},
get(object) {
return object && object[sinonTypeSymbolProperty];
},
};

View file

@ -1,6 +1,6 @@
"use strict";
var array = [null, "once", "twice", "thrice"];
const array = [null, "once", "twice", "thrice"];
module.exports = function timesInWords(count) {
return array[count] || `${count || 0} times`;

View file

@ -1,6 +1,6 @@
"use strict";
var forEach = Array.prototype.forEach;
const forEach = Array.prototype.forEach;
function usePromiseLibrary(library, fakes) {
if (typeof library === "undefined") {

View file

@ -1,13 +1,21 @@
"use strict";
var functionName = require("@sinonjs/commons").functionName;
const functionName = require("@sinonjs/commons").functionName;
var getPropertyDescriptor = require("./get-property-descriptor");
var walk = require("./walk");
const getPropertyDescriptor = require("./get-property-descriptor");
const walk = require("./walk");
function walkObject(predicate, object, filter) {
var called = false;
var name = functionName(predicate);
/**
* A utility that allows traversing an object, applying mutating functions on the properties
*
* @param {Function} mutator called on each property
* @param {object} object the object we are walking over
* @param {Function} filter a predicate (boolean function) that will decide whether or not to apply the mutator to the current property
* @returns {void} nothing
*/
function walkObject(mutator, object, filter) {
let called = false;
const name = functionName(mutator);
if (!object) {
throw new Error(
@ -26,17 +34,19 @@ function walkObject(predicate, object, filter) {
if (filter) {
if (filter(object, prop)) {
called = true;
predicate(object, prop);
mutator(object, prop);
}
} else {
called = true;
predicate(object, prop);
mutator(object, prop);
}
}
});
if (!called) {
throw new Error(`Expected to ${name} methods on object but found none`);
throw new Error(
`Found no methods on object to which we could apply mutations`
);
}
return object;

View file

@ -1,9 +1,10 @@
"use strict";
var forEach = require("@sinonjs/commons").prototypes.array.forEach;
const forEach = require("@sinonjs/commons").prototypes.array.forEach;
function walkInternal(obj, iterator, context, originalObj, seen) {
var proto, prop;
let prop;
const proto = Object.getPrototypeOf(obj);
if (typeof Object.getOwnPropertyNames !== "function") {
// We explicitly want to enumerate through all of the prototype's properties
@ -19,7 +20,7 @@ function walkInternal(obj, iterator, context, originalObj, seen) {
forEach(Object.getOwnPropertyNames(obj), function (k) {
if (seen[k] !== true) {
seen[k] = true;
var target =
const target =
typeof Object.getOwnPropertyDescriptor(obj, k).get ===
"function"
? originalObj
@ -28,7 +29,6 @@ function walkInternal(obj, iterator, context, originalObj, seen) {
}
});
proto = Object.getPrototypeOf(obj);
if (proto) {
walkInternal(proto, iterator, context, originalObj, seen);
}

View file

@ -1,11 +1,14 @@
"use strict";
var getPropertyDescriptor = require("./get-property-descriptor");
var extend = require("./extend");
var hasOwnProperty =
// eslint-disable-next-line no-empty-function
const noop = () => {};
const getPropertyDescriptor = require("./get-property-descriptor");
const extend = require("./extend");
const sinonType = require("./sinon-type");
const hasOwnProperty =
require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var valueToString = require("@sinonjs/commons").valueToString;
var push = require("@sinonjs/commons").prototypes.array.push;
const valueToString = require("@sinonjs/commons").valueToString;
const push = require("@sinonjs/commons").prototypes.array.push;
function isFunction(obj) {
return (
@ -15,7 +18,7 @@ function isFunction(obj) {
}
function mirrorProperties(target, source) {
for (var prop in source) {
for (const prop in source) {
if (!hasOwnProperty(target, prop)) {
target[prop] = source[prop];
}
@ -23,10 +26,10 @@ function mirrorProperties(target, source) {
}
function getAccessor(object, property, method) {
var accessors = ["get", "set"];
var descriptor = getPropertyDescriptor(object, property);
const accessors = ["get", "set"];
const descriptor = getPropertyDescriptor(object, property);
for (var i = 0; i < accessors.length; i++) {
for (let i = 0; i < accessors.length; i++) {
if (
descriptor[accessors[i]] &&
descriptor[accessors[i]].name === method.name
@ -38,7 +41,7 @@ function getAccessor(object, property, method) {
}
// Cheap way to detect if we have ES5 support.
var hasES5Support = "keys" in Object;
const hasES5Support = "keys" in Object;
module.exports = function wrapMethod(object, property, method) {
if (!object) {
@ -52,7 +55,7 @@ module.exports = function wrapMethod(object, property, method) {
}
function checkWrappedMethod(wrappedMethod) {
var error;
let error;
if (!isFunction(wrappedMethod)) {
error = new TypeError(
@ -67,7 +70,7 @@ module.exports = function wrapMethod(object, property, method) {
)} which is already wrapped`
);
} else if (wrappedMethod.calledBefore) {
var verb = wrappedMethod.returns ? "stubbed" : "spied on";
const verb = wrappedMethod.returns ? "stubbed" : "spied on";
error = new TypeError(
`Attempted to wrap ${valueToString(
property
@ -83,15 +86,9 @@ module.exports = function wrapMethod(object, property, method) {
}
}
var error,
wrappedMethods,
wrappedMethod,
i,
wrappedMethodDesc,
target,
accessor;
let error, wrappedMethod, i, wrappedMethodDesc, target, accessor;
wrappedMethods = [];
const wrappedMethods = [];
function simplePropertyAssignment() {
wrappedMethod = object[property];
@ -101,12 +98,12 @@ module.exports = function wrapMethod(object, property, method) {
}
// Firefox has a problem when using hasOwn.call on objects from other frames.
var owned = object.hasOwnProperty
const owned = object.hasOwnProperty
? object.hasOwnProperty(property) // eslint-disable-line @sinonjs/no-prototype-methods/no-prototype-methods
: hasOwnProperty(object, property);
if (hasES5Support) {
var methodDesc =
const methodDesc =
typeof method === "function" ? { value: method } : method;
wrappedMethodDesc = getPropertyDescriptor(object, property);
@ -129,7 +126,7 @@ module.exports = function wrapMethod(object, property, method) {
throw error;
}
var types = Object.keys(methodDesc);
const types = Object.keys(methodDesc);
for (i = 0; i < types.length; i++) {
wrappedMethod = wrappedMethodDesc[types[i]];
checkWrappedMethod(wrappedMethod);
@ -140,6 +137,13 @@ module.exports = function wrapMethod(object, property, method) {
for (i = 0; i < types.length; i++) {
mirrorProperties(methodDesc[types[i]], wrappedMethodDesc[types[i]]);
}
// you are not allowed to flip the configurable prop on an
// existing descriptor to anything but false (#2514)
if (!owned) {
methodDesc.configurable = true;
}
Object.defineProperty(object, property, methodDesc);
// catch failing assignment
@ -180,7 +184,7 @@ module.exports = function wrapMethod(object, property, method) {
function restore() {
accessor = getAccessor(object, property, this.wrappedMethod);
var descriptor;
let descriptor;
// For prototype properties try to reset by delete first.
// If this fails (ex: localStorage on mobile safari) then force a reset
// via direct assignment.
@ -230,6 +234,11 @@ module.exports = function wrapMethod(object, property, method) {
}
}
}
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;
}
}
return method;

View file

@ -1,21 +1,31 @@
"use strict";
var extend = require("./core/extend");
var FakeTimers = require("@sinonjs/fake-timers");
var globalObject = require("@sinonjs/commons").global;
const extend = require("./core/extend");
const FakeTimers = require("@sinonjs/fake-timers");
const globalObject = require("@sinonjs/commons").global;
/**
*
* @param config
* @param globalCtx
*/
function createClock(config, globalCtx) {
var FakeTimersCtx = FakeTimers;
let FakeTimersCtx = FakeTimers;
if (globalCtx !== null && typeof globalCtx === "object") {
FakeTimersCtx = FakeTimers.withGlobal(globalCtx);
}
var clock = FakeTimersCtx.install(config);
const clock = FakeTimersCtx.install(config);
clock.restore = clock.uninstall;
return clock;
}
/**
*
* @param obj
* @param globalPropName
*/
function addIfDefined(obj, globalPropName) {
var globalProp = globalObject[globalPropName];
const globalProp = globalObject[globalPropName];
if (typeof globalProp !== "undefined") {
obj[globalPropName] = globalProp;
}
@ -26,11 +36,11 @@ function addIfDefined(obj, globalPropName) {
* @returns {object} Returns a lolex clock instance
*/
exports.useFakeTimers = function (dateOrConfig) {
var hasArguments = typeof dateOrConfig !== "undefined";
var argumentIsDateLike =
const hasArguments = typeof dateOrConfig !== "undefined";
const argumentIsDateLike =
(typeof dateOrConfig === "number" || dateOrConfig instanceof Date) &&
arguments.length === 1;
var argumentIsObject =
const argumentIsObject =
dateOrConfig !== null &&
typeof dateOrConfig === "object" &&
arguments.length === 1;
@ -48,8 +58,8 @@ exports.useFakeTimers = function (dateOrConfig) {
}
if (argumentIsObject) {
var config = extend.nonEnum({}, dateOrConfig);
var globalCtx = config.global;
const config = extend.nonEnum({}, dateOrConfig);
const globalCtx = config.global;
delete config.global;
return createClock(config, globalCtx);
}
@ -65,7 +75,7 @@ exports.clock = {
},
};
var timers = {
const timers = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,

View file

@ -1,6 +1,6 @@
{
"name": "@sinonjs/commons",
"version": "2.0.0",
"version": "3.0.0",
"description": "Simple functions shared among the sinon end user libraries",
"main": "lib/index.js",
"types": "./types/index.d.ts",

View file

@ -255,6 +255,13 @@ Advances the clock to the the moment of the first scheduled timer, firing it.
The `nextAsync()` will also break the event loop, allowing any scheduled promise
callbacks to execute _before_ running the timers.
### `clock.jump(time)`
Advance the clock by jumping forward in time, firing callbacks at most once.
`time` takes the same formats as [`clock.tick`](#clockticktime--await-clocktickasynctime).
This can be used to simulate the JS engine (such as a browser) being put to sleep and resumed later, skipping intermediary timers.
### `clock.reset()`
Removes all timers and ticks without firing them, and sets `now` to `config.now`

View file

@ -1,7 +1,7 @@
{
"name": "@sinonjs/fake-timers",
"description": "Fake JavaScript timers",
"version": "10.0.2",
"version": "10.3.0",
"homepage": "https://github.com/sinonjs/fake-timers",
"author": "Christian Johansen",
"repository": {
@ -36,19 +36,19 @@
"src/"
],
"devDependencies": {
"@sinonjs/eslint-config": "4.0.6",
"@sinonjs/referee-sinon": "10.1.0",
"husky": "^8.0.0",
"jsdom": "20.0.2",
"lint-staged": "13.0.3",
"mocha": "10.1.0",
"@sinonjs/eslint-config": "^4.1.0",
"@sinonjs/referee-sinon": "11.0.0",
"husky": "^8.0.3",
"jsdom": "22.0.0",
"lint-staged": "13.2.2",
"mocha": "10.2.0",
"mochify": "9.2.0",
"nyc": "15.1.0",
"prettier": "2.7.1"
"prettier": "2.8.8"
},
"main": "./src/fake-timers-src.js",
"dependencies": {
"@sinonjs/commons": "^2.0.0"
"@sinonjs/commons": "^3.0.0"
},
"nyc": {
"branches": 85,

View file

@ -79,6 +79,7 @@ const globalObject = require("@sinonjs/commons").global;
* @property {function(): Promise<number>} runToLastAsync
* @property {function(): void} reset
* @property {function(number | Date): void} setSystemTime
* @property {function(number): void} jump
* @property {Performance} performance
* @property {function(number[]): number[]} hrtime - process.hrtime (legacy)
* @property {function(): void} uninstall Uninstall the clock.
@ -1605,6 +1606,25 @@ function withGlobal(_global) {
}
};
/**
* @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
* @returns {number} will return the new `now` value
*/
clock.jump = function jump(tickValue) {
const msFloat =
typeof tickValue === "number"
? tickValue
: parseTime(tickValue);
const ms = Math.floor(msFloat);
for (const timer of Object.values(clock.timers)) {
if (clock.now + ms > timer.callAt) {
timer.callAt = clock.now + ms;
}
}
clock.tick(ms);
};
if (performancePresent) {
clock.performance = Object.create(null);
clock.performance.now = fakePerformanceNow;

41
node_modules/sinon/package.json generated vendored
View file

@ -15,7 +15,7 @@
"xhr",
"assert"
],
"version": "15.0.1",
"version": "15.2.0",
"homepage": "https://sinonjs.org/",
"author": "Christian Johansen",
"repository": {
@ -46,7 +46,7 @@
"build": "node ./build.cjs",
"build-docs": "cd docs; bundle exec jekyll build",
"serve-docs": "cd docs; bundle exec jekyll serve --incremental --verbose",
"lint": "eslint '**/*.{js,cjs,mjs}'",
"lint": "eslint --max-warnings 99 '**/*.{js,cjs,mjs}'",
"unimported": "unimported .",
"pretest-webworker": "npm run build",
"prebuild": "rimraf pkg && npm run check-dependencies",
@ -73,38 +73,38 @@
"*.mjs": "eslint --quiet --ext mjs --parser-options=sourceType:module"
},
"dependencies": {
"@sinonjs/commons": "^2.0.0",
"@sinonjs/fake-timers": "10.0.2",
"@sinonjs/samsam": "^7.0.1",
"diff": "^5.0.0",
"nise": "^5.1.2",
"@sinonjs/commons": "^3.0.0",
"@sinonjs/fake-timers": "^10.3.0",
"@sinonjs/samsam": "^8.0.0",
"diff": "^5.1.0",
"nise": "^5.1.4",
"supports-color": "^7.2.0"
},
"devDependencies": {
"@babel/core": "^7.16.12",
"@sinonjs/eslint-config": "^4.0.5",
"@babel/core": "^7.21.0",
"@sinonjs/eslint-config": "^4.0.6",
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1",
"@sinonjs/referee": "^9.1.1",
"@sinonjs/referee": "^10.0.0",
"@studio/changes": "^2.2.0",
"babel-plugin-istanbul": "^6.1.1",
"babelify": "^10.0.0",
"browserify": "^16.5.2",
"debug": "^4.3.1",
"debug": "^4.3.4",
"dependency-check": "^4.1.0",
"husky": "^6.0.0",
"lint-staged": "^12.3.2",
"mocha": "^9.2.0",
"mochify": "^9.1.0",
"lint-staged": "^13.2.0",
"mocha": "^10.2.0",
"mochify": "^9.2.0",
"nyc": "^15.1.0",
"prettier": "^2.5.1",
"prettier": "^2.8.4",
"proxyquire": "^2.1.3",
"proxyquire-universal": "^3.0.1",
"proxyquireify": "^3.2.1",
"puppeteer": "^13.1.2",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"shelljs": "^0.8.4",
"unimported": "^1.20.0"
"puppeteer": "^19.7.4",
"rimraf": "^4.4.0",
"semver": "^7.3.8",
"shelljs": "^0.8.5",
"unimported": "^1.26.0"
},
"files": [
"lib",
@ -121,6 +121,7 @@
"module": "./pkg/sinon-esm.js",
"exports": {
".": {
"browser": "./pkg/sinon-esm.js",
"require": "./lib/sinon.js",
"import": "./pkg/sinon-esm.js"
},

3138
node_modules/sinon/pkg/sinon-esm.js generated vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

3140
node_modules/sinon/pkg/sinon.js generated vendored

File diff suppressed because one or more lines are too long