sinon
Version:
JavaScript test spies, stubs and mocks.
1,363 lines (1,321 loc) • 1.44 MB
JavaScript
/* Sinon.JS 21.1.2, 2026-04-11, @license BSD-3 */(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f(require)}else if("function"==typeof define && define.amd){define("sinon",["timers","timers/promises","fs"],function(_d_0,_d_1,_d_2){var d={"timers": _d_0,"timers/promises": _d_1,"fs": _d_2},r=function(m){if(m in d) return d[m];if(typeof require=="function") return require(m);throw new Error("Cannot find module '"+m+"'")};return f(r)})}else {var gN={"timers":"timers","timers/promises":"timers/promises","fs":"fs"},gReq=function(r){var mod = r in gN ? g[gN[r]] : g[r]; return mod };g["sinon"]=f(gReq)}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(require){var exports={};var __exports=exports;var module={exports};
"use strict";
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
// node_modules/@sinonjs/commons/lib/global.js
var require_global = __commonJS({
"node_modules/@sinonjs/commons/lib/global.js"(exports2, module2) {
"use strict";
var globalObject;
if (typeof global !== "undefined") {
globalObject = global;
} else if (typeof window !== "undefined") {
globalObject = window;
} else {
globalObject = self;
}
module2.exports = globalObject;
}
});
// node_modules/@sinonjs/commons/lib/prototypes/throws-on-proto.js
var require_throws_on_proto = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/throws-on-proto.js"(exports2, module2) {
"use strict";
var throwsOnProto;
try {
const object = {};
object.__proto__;
throwsOnProto = false;
} catch (_) {
throwsOnProto = true;
}
module2.exports = throwsOnProto;
}
});
// node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js
var require_copy_prototype_methods = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js"(exports2, module2) {
"use strict";
var call = Function.call;
var throwsOnProto = require_throws_on_proto();
var disallowedProperties = [
// ignore size because it throws from Map
"size",
"caller",
"callee",
"arguments"
];
if (throwsOnProto) {
disallowedProperties.push("__proto__");
}
module2.exports = function copyPrototypeMethods(prototype) {
return Object.getOwnPropertyNames(prototype).reduce(
function(result, name) {
if (disallowedProperties.includes(name)) {
return result;
}
if (typeof prototype[name] !== "function") {
return result;
}
result[name] = call.bind(prototype[name]);
return result;
},
/* @__PURE__ */ Object.create(null)
);
};
}
});
// node_modules/@sinonjs/commons/lib/prototypes/array.js
var require_array = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/array.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(Array.prototype);
}
});
// node_modules/@sinonjs/commons/lib/called-in-order.js
var require_called_in_order = __commonJS({
"node_modules/@sinonjs/commons/lib/called-in-order.js"(exports2, module2) {
"use strict";
var every = require_array().every;
function hasCallsLeft(callMap, spy) {
if (callMap[spy.id] === void 0) {
callMap[spy.id] = 0;
}
return callMap[spy.id] < spy.callCount;
}
function checkAdjacentCalls(callMap, spy, index, spies) {
var calledBeforeNext = true;
if (index !== spies.length - 1) {
calledBeforeNext = spy.calledBefore(spies[index + 1]);
}
if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
callMap[spy.id] += 1;
return true;
}
return false;
}
function calledInOrder(spies) {
var callMap = {};
var _spies = arguments.length > 1 ? arguments : spies;
return every(_spies, checkAdjacentCalls.bind(null, callMap));
}
module2.exports = calledInOrder;
}
});
// node_modules/@sinonjs/commons/lib/class-name.js
var require_class_name = __commonJS({
"node_modules/@sinonjs/commons/lib/class-name.js"(exports2, module2) {
"use strict";
function className(value) {
const name = value.constructor && value.constructor.name;
return name || null;
}
module2.exports = className;
}
});
// node_modules/@sinonjs/commons/lib/deprecated.js
var require_deprecated = __commonJS({
"node_modules/@sinonjs/commons/lib/deprecated.js"(exports2) {
"use strict";
exports2.wrap = function(func, msg) {
var wrapped = function() {
exports2.printWarning(msg);
return func.apply(this, arguments);
};
if (func.prototype) {
wrapped.prototype = func.prototype;
}
return wrapped;
};
exports2.defaultMsg = function(packageName, funcName) {
return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
};
exports2.printWarning = function(msg) {
if (typeof process === "object" && process.emitWarning) {
process.emitWarning(msg);
} else if (console.info) {
console.info(msg);
} else {
console.log(msg);
}
};
}
});
// node_modules/@sinonjs/commons/lib/every.js
var require_every = __commonJS({
"node_modules/@sinonjs/commons/lib/every.js"(exports2, module2) {
"use strict";
module2.exports = function every(obj, fn) {
var pass = true;
try {
obj.forEach(function() {
if (!fn.apply(this, arguments)) {
throw new Error();
}
});
} catch (e) {
pass = false;
}
return pass;
};
}
});
// node_modules/@sinonjs/commons/lib/function-name.js
var require_function_name = __commonJS({
"node_modules/@sinonjs/commons/lib/function-name.js"(exports2, module2) {
"use strict";
module2.exports = function functionName(func) {
if (!func) {
return "";
}
try {
return func.displayName || func.name || // Use function decomposition as a last resort to get function
// name. Does not rely on function decomposition to work - if it
// doesn't debugging will be slightly less informative
// (i.e. toString will say 'spy' rather than 'myFunc').
(String(func).match(/function ([^\s(]+)/) || [])[1];
} catch (e) {
return "";
}
};
}
});
// node_modules/@sinonjs/commons/lib/order-by-first-call.js
var require_order_by_first_call = __commonJS({
"node_modules/@sinonjs/commons/lib/order-by-first-call.js"(exports2, module2) {
"use strict";
var sort = require_array().sort;
var slice = require_array().slice;
function comparator(a, b) {
var aCall = a.getCall(0);
var bCall = b.getCall(0);
var aId = aCall && aCall.callId || -1;
var bId = bCall && bCall.callId || -1;
return aId < bId ? -1 : 1;
}
function orderByFirstCall(spies) {
return sort(slice(spies), comparator);
}
module2.exports = orderByFirstCall;
}
});
// node_modules/@sinonjs/commons/lib/prototypes/function.js
var require_function = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/function.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(Function.prototype);
}
});
// node_modules/@sinonjs/commons/lib/prototypes/map.js
var require_map = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/map.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(Map.prototype);
}
});
// node_modules/@sinonjs/commons/lib/prototypes/object.js
var require_object = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/object.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(Object.prototype);
}
});
// node_modules/@sinonjs/commons/lib/prototypes/set.js
var require_set = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/set.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(Set.prototype);
}
});
// node_modules/@sinonjs/commons/lib/prototypes/string.js
var require_string = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/string.js"(exports2, module2) {
"use strict";
var copyPrototype = require_copy_prototype_methods();
module2.exports = copyPrototype(String.prototype);
}
});
// node_modules/@sinonjs/commons/lib/prototypes/index.js
var require_prototypes = __commonJS({
"node_modules/@sinonjs/commons/lib/prototypes/index.js"(exports2, module2) {
"use strict";
module2.exports = {
array: require_array(),
function: require_function(),
map: require_map(),
object: require_object(),
set: require_set(),
string: require_string()
};
}
});
// node_modules/type-detect/type-detect.js
var require_type_detect = __commonJS({
"node_modules/type-detect/type-detect.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.typeDetect = factory();
})(exports2, (function() {
"use strict";
var promiseExists = typeof Promise === "function";
var globalObject = typeof self === "object" ? self : global;
var symbolExists = typeof Symbol !== "undefined";
var mapExists = typeof Map !== "undefined";
var setExists = typeof Set !== "undefined";
var weakMapExists = typeof WeakMap !== "undefined";
var weakSetExists = typeof WeakSet !== "undefined";
var dataViewExists = typeof DataView !== "undefined";
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
var toStringLeftSliceLength = 8;
var toStringRightSliceLength = -1;
function typeDetect(obj) {
var typeofObj = typeof obj;
if (typeofObj !== "object") {
return typeofObj;
}
if (obj === null) {
return "null";
}
if (obj === globalObject) {
return "global";
}
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
return "Array";
}
if (typeof window === "object" && window !== null) {
if (typeof window.location === "object" && obj === window.location) {
return "Location";
}
if (typeof window.document === "object" && obj === window.document) {
return "Document";
}
if (typeof window.navigator === "object") {
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
return "MimeTypeArray";
}
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
return "PluginArray";
}
}
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
if (obj.tagName === "BLOCKQUOTE") {
return "HTMLQuoteElement";
}
if (obj.tagName === "TD") {
return "HTMLTableDataCellElement";
}
if (obj.tagName === "TH") {
return "HTMLTableHeaderCellElement";
}
}
}
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
if (typeof stringTag === "string") {
return stringTag;
}
var objPrototype = Object.getPrototypeOf(obj);
if (objPrototype === RegExp.prototype) {
return "RegExp";
}
if (objPrototype === Date.prototype) {
return "Date";
}
if (promiseExists && objPrototype === Promise.prototype) {
return "Promise";
}
if (setExists && objPrototype === Set.prototype) {
return "Set";
}
if (mapExists && objPrototype === Map.prototype) {
return "Map";
}
if (weakSetExists && objPrototype === WeakSet.prototype) {
return "WeakSet";
}
if (weakMapExists && objPrototype === WeakMap.prototype) {
return "WeakMap";
}
if (dataViewExists && objPrototype === DataView.prototype) {
return "DataView";
}
if (mapExists && objPrototype === mapIteratorPrototype) {
return "Map Iterator";
}
if (setExists && objPrototype === setIteratorPrototype) {
return "Set Iterator";
}
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
return "Array Iterator";
}
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
return "String Iterator";
}
if (objPrototype === null) {
return "Object";
}
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
}
return typeDetect;
}));
}
});
// node_modules/@sinonjs/commons/lib/type-of.js
var require_type_of = __commonJS({
"node_modules/@sinonjs/commons/lib/type-of.js"(exports2, module2) {
"use strict";
var type = require_type_detect();
module2.exports = function typeOf(value) {
return type(value).toLowerCase();
};
}
});
// node_modules/@sinonjs/commons/lib/value-to-string.js
var require_value_to_string = __commonJS({
"node_modules/@sinonjs/commons/lib/value-to-string.js"(exports2, module2) {
"use strict";
function valueToString(value) {
if (value && value.toString) {
return value.toString();
}
return String(value);
}
module2.exports = valueToString;
}
});
// node_modules/@sinonjs/commons/lib/index.js
var require_lib = __commonJS({
"node_modules/@sinonjs/commons/lib/index.js"(exports2, module2) {
"use strict";
module2.exports = {
global: require_global(),
calledInOrder: require_called_in_order(),
className: require_class_name(),
deprecated: require_deprecated(),
every: require_every(),
functionName: require_function_name(),
orderByFirstCall: require_order_by_first_call(),
prototypes: require_prototypes(),
typeOf: require_type_of(),
valueToString: require_value_to_string()
};
}
});
// lib/sinon/util/core/extend.js
var require_extend = __commonJS({
"lib/sinon/util/core/extend.js"(exports2, module2) {
"use strict";
var commons = require_lib();
function _interopDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var commons__default = /* @__PURE__ */ _interopDefault(commons);
var { prototypes: commonsPrototypes } = commons__default.default;
var { array: arrayProto, object: objectProto } = commonsPrototypes;
var { hasOwnProperty } = objectProto;
var join = arrayProto.join;
var push = arrayProto.push;
var hasDontEnumBug = (function() {
const obj = {
constructor: function() {
return "0";
},
toString: function() {
return "1";
},
valueOf: function() {
return "2";
},
toLocaleString: function() {
return "3";
},
prototype: function() {
return "4";
},
isPrototypeOf: function() {
return "5";
},
propertyIsEnumerable: function() {
return "6";
},
hasOwnProperty: function() {
return "7";
},
length: function() {
return "8";
},
unique: function() {
return "9";
}
};
const result = [];
for (const prop in obj) {
if (hasOwnProperty(obj, prop)) {
push(result, obj[prop]());
}
}
return join(result, "") !== "0123456789";
})();
function extendCommon(target, sources, doCopy) {
let source, i, prop;
for (i = 0; i < sources.length; i++) {
source = sources[i];
for (prop in source) {
if (hasOwnProperty(source, prop)) {
doCopy(target, source, prop);
}
}
if (hasDontEnumBug && hasOwnProperty(source, "toString") && source.toString !== target.toString) {
target.toString = source.toString;
}
}
return target;
}
function extend(target, ...sources) {
return extendCommon(
target,
sources,
function copyValue(dest, source, prop) {
const destOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
dest,
prop
);
const sourceOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
source,
prop
);
if (prop === "name" && (!destOwnPropertyDescriptor || !destOwnPropertyDescriptor.writable)) {
return;
}
const descriptors = {
configurable: sourceOwnPropertyDescriptor.configurable,
enumerable: sourceOwnPropertyDescriptor.enumerable
};
if (hasOwnProperty(sourceOwnPropertyDescriptor, "writable")) {
descriptors.writable = sourceOwnPropertyDescriptor.writable;
descriptors.value = sourceOwnPropertyDescriptor.value;
} else {
if (sourceOwnPropertyDescriptor.get) {
descriptors.get = sourceOwnPropertyDescriptor.get.bind(dest);
}
if (sourceOwnPropertyDescriptor.set) {
descriptors.set = sourceOwnPropertyDescriptor.set.bind(dest);
}
}
Object.defineProperty(dest, prop, descriptors);
}
);
}
extend.nonEnum = function extendNonEnum(target, ...sources) {
return extendCommon(
target,
sources,
function copyProperty(dest, source, prop) {
Object.defineProperty(dest, prop, {
value: source[prop],
enumerable: false,
configurable: true,
writable: true
});
}
);
};
module2.exports = extend;
}
});
// lib/sinon/util/core/get-next-tick.js
var require_get_next_tick = __commonJS({
"lib/sinon/util/core/get-next-tick.js"(exports2, module2) {
"use strict";
function nextTick(callback) {
setTimeout(callback, 0);
}
function getNextTick(process2, setImmediate) {
if (typeof process2 === "object" && typeof process2.nextTick === "function") {
return process2.nextTick;
}
if (typeof setImmediate === "function") {
return setImmediate;
}
return nextTick;
}
module2.exports = getNextTick;
}
});
// lib/sinon/util/core/next-tick.js
var require_next_tick = __commonJS({
"lib/sinon/util/core/next-tick.js"(exports2, module2) {
"use strict";
var commons = require_lib();
var getNextTick = require_get_next_tick();
function _interopDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var commons__default = /* @__PURE__ */ _interopDefault(commons);
var { global: globalObject } = commons__default.default;
var nextTick = getNextTick(globalObject.process, globalObject.setImmediate);
module2.exports = nextTick;
}
});
// lib/sinon/util/core/export-async-behaviors.js
var require_export_async_behaviors = __commonJS({
"lib/sinon/util/core/export-async-behaviors.js"(exports2, module2) {
"use strict";
var commons = require_lib();
function _interopDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var commons__default = /* @__PURE__ */ _interopDefault(commons);
var { prototypes } = commons__default.default;
var { reduce } = prototypes.array;
function exportAsyncBehaviors(behaviorMethods) {
return reduce(
Object.keys(behaviorMethods),
function(acc, method) {
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
acc[`${method}Async`] = function() {
const result = behaviorMethods[method].apply(
this,
arguments
);
this.callbackAsync = true;
return result;
};
}
return acc;
},
{}
);
}
module2.exports = exportAsyncBehaviors;
}
});
// lib/sinon/behavior.js
var require_behavior = __commonJS({
"lib/sinon/behavior.js"(exports2, module2) {
"use strict";
var commons = require_lib();
var extend = require_extend();
var nextTick = require_next_tick();
var exportAsyncBehaviors = require_export_async_behaviors();
function _interopDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var commons__default = /* @__PURE__ */ _interopDefault(commons);
var { prototypes: commonsPrototypes, functionName, valueToString } = commons__default.default;
var { array: arrayProto } = commonsPrototypes;
var concat = arrayProto.concat;
var join = arrayProto.join;
var reverse = arrayProto.reverse;
var slice = arrayProto.slice;
var useLeftMostCallback = -1;
var useRightMostCallback = -2;
function getCallback(behavior2, args) {
const callArgAt = behavior2.callArgAt;
if (callArgAt >= 0) {
return args[callArgAt];
}
let argumentList;
if (callArgAt === useLeftMostCallback) {
argumentList = args;
}
if (callArgAt === useRightMostCallback) {
argumentList = reverse(slice(args));
}
const callArgProp = behavior2.callArgProp;
for (let i = 0, l = argumentList.length; i < l; ++i) {
if (!callArgProp && typeof argumentList[i] === "function") {
return argumentList[i];
}
if (callArgProp && argumentList[i] && typeof argumentList[i][callArgProp] === "function") {
return argumentList[i][callArgProp];
}
}
return null;
}
function getCallbackError(behavior2, func, args) {
if (behavior2.callArgAt < 0) {
let msg;
if (behavior2.callArgProp) {
msg = `${functionName(
behavior2.stub
)} expected to yield to '${valueToString(
behavior2.callArgProp
)}', but no object with such a property was passed.`;
} else {
msg = `${functionName(
behavior2.stub
)} expected to yield, but no callback was passed.`;
}
if (args.length > 0) {
msg += ` Received [${join(args, ", ")}]`;
}
return msg;
}
return `argument at index ${behavior2.callArgAt} is not a function: ${func}`;
}
function ensureArgs(name, behavior2, args) {
const property = name.replace(/sArg/, "ArgAt");
const index = behavior2[property];
if (index >= args.length) {
throw new TypeError(
`${name} failed: ${index + 1} arguments required but only ${args.length} present`
);
}
}
function callCallback(behavior2, args) {
if (typeof behavior2.callArgAt === "number") {
ensureArgs("callsArg", behavior2, args);
const func = getCallback(behavior2, args);
if (typeof func !== "function") {
throw new TypeError(getCallbackError(behavior2, func, args));
}
if (behavior2.callbackAsync) {
nextTick(function() {
func.apply(
behavior2.callbackContext,
behavior2.callbackArguments
);
});
} else {
return func.apply(
behavior2.callbackContext,
behavior2.callbackArguments
);
}
}
return void 0;
}
var proto = {
create: function create(stub) {
const behavior2 = extend({}, proto);
delete behavior2.create;
delete behavior2.addBehavior;
delete behavior2.createBehavior;
behavior2.stub = stub;
if (stub.defaultBehavior && stub.defaultBehavior.promiseLibrary) {
behavior2.promiseLibrary = stub.defaultBehavior.promiseLibrary;
}
return behavior2;
},
isPresent: function isPresent() {
return typeof this.callArgAt === "number" || this.exception || this.exceptionCreator || typeof this.returnArgAt === "number" || this.returnThis || typeof this.resolveArgAt === "number" || this.resolveThis || typeof this.throwArgAt === "number" || this.fakeFn || this.returnValueDefined;
},
/*eslint complexity: ["error", 20]*/
invoke: function invoke(context, args) {
const returnValue = callCallback(this, args);
if (this.exception) {
throw this.exception;
} else if (this.exceptionCreator) {
this.exception = this.exceptionCreator();
this.exceptionCreator = void 0;
throw this.exception;
} else if (typeof this.returnArgAt === "number") {
ensureArgs("returnsArg", this, args);
return args[this.returnArgAt];
} else if (this.returnThis) {
return context;
} else if (typeof this.throwArgAt === "number") {
ensureArgs("throwsArg", this, args);
throw args[this.throwArgAt];
} else if (this.fakeFn) {
return this.fakeFn.apply(context, args);
} else if (typeof this.resolveArgAt === "number") {
ensureArgs("resolvesArg", this, args);
return (this.promiseLibrary || Promise).resolve(
args[this.resolveArgAt]
);
} else if (this.resolveThis) {
return (this.promiseLibrary || Promise).resolve(context);
} else if (this.resolve) {
return (this.promiseLibrary || Promise).resolve(this.returnValue);
} else if (this.reject) {
return (this.promiseLibrary || Promise).reject(this.returnValue);
} else if (this.callsThrough) {
const wrappedMethod = this.effectiveWrappedMethod();
return wrappedMethod.apply(context, args);
} else if (this.callsThroughWithNew) {
const WrappedClass = this.effectiveWrappedMethod();
const argsArray = slice(args);
const F = WrappedClass.bind.apply(
WrappedClass,
concat([null], argsArray)
);
return new F();
} else if (typeof this.returnValue !== "undefined") {
return this.returnValue;
} else if (typeof this.callArgAt === "number") {
return returnValue;
}
return this.returnValue;
},
effectiveWrappedMethod: function effectiveWrappedMethod() {
for (let stubb = this.stub; stubb; stubb = stubb.parent) {
if (stubb.wrappedMethod) {
return stubb.wrappedMethod;
}
}
throw new Error("Unable to find wrapped method");
},
onCall: function onCall(index) {
return this.stub.onCall(index);
},
onFirstCall: function onFirstCall() {
return this.stub.onFirstCall();
},
onSecondCall: function onSecondCall() {
return this.stub.onSecondCall();
},
onThirdCall: function onThirdCall() {
return this.stub.onThirdCall();
},
withArgs: function withArgs() {
throw new Error(
'Defining a stub by invoking "stub.onCall(...).withArgs(...)" is not supported. Use "stub.withArgs(...).onCall(...)" to define sequential behavior for calls with certain arguments.'
);
}
};
function createBehavior(behaviorMethod) {
return function() {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(
this.defaultBehavior,
arguments
);
return this;
};
}
function addBehavior(stub, name, fn) {
proto[name] = function() {
fn.apply(this, concat([this], slice(arguments)));
return this.stub || this;
};
stub[name] = createBehavior(name);
}
proto.addBehavior = addBehavior;
proto.createBehavior = createBehavior;
var asyncBehaviors = exportAsyncBehaviors(proto);
var behavior = extend.nonEnum({}, proto, asyncBehaviors);
module2.exports = behavior;
}
});
// node_modules/@sinonjs/samsam/lib/is-nan.js
var require_is_nan = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-nan.js"(exports2, module2) {
"use strict";
function isNaN2(value) {
return typeof value === "number" && value !== value;
}
module2.exports = isNaN2;
}
});
// node_modules/@sinonjs/samsam/lib/is-neg-zero.js
var require_is_neg_zero = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-neg-zero.js"(exports2, module2) {
"use strict";
function isNegZero(value) {
return value === 0 && 1 / value === -Infinity;
}
module2.exports = isNegZero;
}
});
// node_modules/@sinonjs/samsam/lib/identical.js
var require_identical = __commonJS({
"node_modules/@sinonjs/samsam/lib/identical.js"(exports2, module2) {
"use strict";
var isNaN2 = require_is_nan();
var isNegZero = require_is_neg_zero();
function identical(obj1, obj2) {
if (obj1 === obj2 || isNaN2(obj1) && isNaN2(obj2)) {
return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2);
}
return false;
}
module2.exports = identical;
}
});
// node_modules/@sinonjs/samsam/lib/get-class.js
var require_get_class = __commonJS({
"node_modules/@sinonjs/samsam/lib/get-class.js"(exports2, module2) {
"use strict";
var toString = require_lib().prototypes.object.toString;
function getClass(value) {
return toString(value).split(/[ \]]/)[1];
}
module2.exports = getClass;
}
});
// node_modules/@sinonjs/samsam/lib/is-arguments.js
var require_is_arguments = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-arguments.js"(exports2, module2) {
"use strict";
var getClass = require_get_class();
function isArguments(object) {
return getClass(object) === "Arguments";
}
module2.exports = isArguments;
}
});
// node_modules/@sinonjs/samsam/lib/is-element.js
var require_is_element = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-element.js"(exports2, module2) {
"use strict";
var div = typeof document !== "undefined" && document.createElement("div");
function isElement(object) {
if (!object || object.nodeType !== 1 || !div) {
return false;
}
try {
object.appendChild(div);
object.removeChild(div);
} catch (e) {
return false;
}
return true;
}
module2.exports = isElement;
}
});
// node_modules/@sinonjs/samsam/lib/is-set.js
var require_is_set = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-set.js"(exports2, module2) {
"use strict";
function isSet(val) {
return typeof Set !== "undefined" && val instanceof Set || false;
}
module2.exports = isSet;
}
});
// node_modules/@sinonjs/samsam/lib/is-map.js
var require_is_map = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-map.js"(exports2, module2) {
"use strict";
function isMap(value) {
return typeof Map !== "undefined" && value instanceof Map;
}
module2.exports = isMap;
}
});
// node_modules/@sinonjs/samsam/node_modules/type-detect/type-detect.js
var require_type_detect2 = __commonJS({
"node_modules/@sinonjs/samsam/node_modules/type-detect/type-detect.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.typeDetect = factory());
})(exports2, (function() {
"use strict";
var promiseExists = typeof Promise === "function";
var globalObject = (function(Obj) {
if (typeof globalThis === "object") {
return globalThis;
}
Object.defineProperty(Obj, "typeDetectGlobalObject", {
get: function get() {
return this;
},
configurable: true
});
var global2 = typeDetectGlobalObject;
delete Obj.typeDetectGlobalObject;
return global2;
})(Object.prototype);
var symbolExists = typeof Symbol !== "undefined";
var mapExists = typeof Map !== "undefined";
var setExists = typeof Set !== "undefined";
var weakMapExists = typeof WeakMap !== "undefined";
var weakSetExists = typeof WeakSet !== "undefined";
var dataViewExists = typeof DataView !== "undefined";
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
var toStringLeftSliceLength = 8;
var toStringRightSliceLength = -1;
function typeDetect(obj) {
var typeofObj = typeof obj;
if (typeofObj !== "object") {
return typeofObj;
}
if (obj === null) {
return "null";
}
if (obj === globalObject) {
return "global";
}
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
return "Array";
}
if (typeof window === "object" && window !== null) {
if (typeof window.location === "object" && obj === window.location) {
return "Location";
}
if (typeof window.document === "object" && obj === window.document) {
return "Document";
}
if (typeof window.navigator === "object") {
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
return "MimeTypeArray";
}
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
return "PluginArray";
}
}
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
if (obj.tagName === "BLOCKQUOTE") {
return "HTMLQuoteElement";
}
if (obj.tagName === "TD") {
return "HTMLTableDataCellElement";
}
if (obj.tagName === "TH") {
return "HTMLTableHeaderCellElement";
}
}
}
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
if (typeof stringTag === "string") {
return stringTag;
}
var objPrototype = Object.getPrototypeOf(obj);
if (objPrototype === RegExp.prototype) {
return "RegExp";
}
if (objPrototype === Date.prototype) {
return "Date";
}
if (promiseExists && objPrototype === Promise.prototype) {
return "Promise";
}
if (setExists && objPrototype === Set.prototype) {
return "Set";
}
if (mapExists && objPrototype === Map.prototype) {
return "Map";
}
if (weakSetExists && objPrototype === WeakSet.prototype) {
return "WeakSet";
}
if (weakMapExists && objPrototype === WeakMap.prototype) {
return "WeakMap";
}
if (dataViewExists && objPrototype === DataView.prototype) {
return "DataView";
}
if (mapExists && objPrototype === mapIteratorPrototype) {
return "Map Iterator";
}
if (setExists && objPrototype === setIteratorPrototype) {
return "Set Iterator";
}
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
return "Array Iterator";
}
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
return "String Iterator";
}
if (objPrototype === null) {
return "Object";
}
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
}
return typeDetect;
}));
}
});
// node_modules/@sinonjs/samsam/lib/array-types.js
var require_array_types = __commonJS({
"node_modules/@sinonjs/samsam/lib/array-types.js"(exports2, module2) {
"use strict";
var ARRAY_TYPES = [
Array,
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
];
module2.exports = ARRAY_TYPES;
}
});
// node_modules/@sinonjs/samsam/lib/is-array-type.js
var require_is_array_type = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-array-type.js"(exports2, module2) {
"use strict";
var functionName = require_lib().functionName;
var indexOf = require_lib().prototypes.array.indexOf;
var map = require_lib().prototypes.array.map;
var ARRAY_TYPES = require_array_types();
var type = require_type_detect2();
function isArrayType(object) {
return indexOf(map(ARRAY_TYPES, functionName), type(object)) !== -1;
}
module2.exports = isArrayType;
}
});
// node_modules/@sinonjs/samsam/lib/is-date.js
var require_is_date = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-date.js"(exports2, module2) {
"use strict";
function isDate(value) {
return value instanceof Date;
}
module2.exports = isDate;
}
});
// node_modules/@sinonjs/samsam/lib/is-iterable.js
var require_is_iterable = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-iterable.js"(exports2, module2) {
"use strict";
function isIterable(val) {
if (typeof val !== "object") {
return false;
}
return typeof val[Symbol.iterator] === "function";
}
module2.exports = isIterable;
}
});
// node_modules/@sinonjs/samsam/lib/is-object.js
var require_is_object = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-object.js"(exports2, module2) {
"use strict";
function isObject(value) {
return typeof value === "object" && value !== null && // none of these are collection objects, so we can return false
!(value instanceof Boolean) && !(value instanceof Date) && !(value instanceof Error) && !(value instanceof Number) && !(value instanceof RegExp) && !(value instanceof String);
}
module2.exports = isObject;
}
});
// node_modules/@sinonjs/samsam/lib/is-subset.js
var require_is_subset = __commonJS({
"node_modules/@sinonjs/samsam/lib/is-subset.js"(exports2, module2) {
"use strict";
var forEach = require_lib().prototypes.set.forEach;
function isSubset(s1, s2, compare) {
var allContained = true;
forEach(s1, function(v1) {
var includes = false;
forEach(s2, function(v2) {
if (compare(v2, v1)) {
includes = true;
}
});
allContained = allContained && includes;
});
return allContained;
}
module2.exports = isSubset;
}
});
// node_modules/@sinonjs/samsam/lib/deep-equal.js
var require_deep_equal = __commonJS({
"node_modules/@sinonjs/samsam/lib/deep-equal.js"(exports2, module2) {
"use strict";
var valueToString = require_lib().valueToString;
var className = require_lib().className;
var typeOf = require_lib().typeOf;
var arrayProto = require_lib().prototypes.array;
var mapForEach = require_lib().prototypes.map.forEach;
var getClass = require_get_class();
var identical = require_identical();
var isArguments = require_is_arguments();
var isArrayType = require_is_array_type();
var isDate = require_is_date();
var isElement = require_is_element();
var isIterable = require_is_iterable();
var isMap = require_is_map();
var isNaN2 = require_is_nan();
var isObject = require_is_object();
var isSet = require_is_set();
var isSubset = require_is_subset();
var concat = arrayProto.concat;
var every = arrayProto.every;
var push = arrayProto.push;
var getTime = Date.prototype.getTime;
var indexOf = arrayProto.indexOf;
var objectKeys = Object.keys;
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
function allEnumerableKeysInProtoChain(object) {
const enumerableKeys = [];
for (const key in object) {
enumerableKeys.push(key);
}
return enumerableKeys;
}
function shouldComparePrototypeEnumerableKeys(object) {
return !isArrayType(object) && !isArguments(object);
}
function getEnumerableStringKeys(object) {
return shouldComparePrototypeEnumerableKeys(object) ? allEnumerableKeysInProtoChain(object) : objectKeys(object);
}
function hasAllEnumerableStringKeys(actualKeys, expectedKeys) {
return every(expectedKeys, function(key) {
return indexOf(actualKeys, key) !== -1;
});
}
function deepEqualCyclic(actual, expectation, match) {
var actualObjects = [];
var expectationObjects = [];
var actualPaths = [];
var expectationPaths = [];
var compared = {};
return (function deepEqual(actualObj, expectationObj, actualPath, expectationPath) {
if (match && match.isMatcher(expectationObj)) {
if (match.isMatcher(actualObj)) {
return actualObj === expectationObj;
}
return expectationObj.test(actualObj);
}
var actualType = typeof actualObj;
var expectationType = typeof expectationObj;
if (actualObj === expectationObj || isNaN2(actualObj) || isNaN2(expectationObj) || actualObj === null || expectationObj === null || actualObj === void 0 || expectationObj === void 0 || actualType !== "object" || expectationType !== "object") {
return identical(actualObj, expectationObj);
}
if (isElement(actualObj) || isElement(expectationObj)) {
return false;
}
var isActualDate = isDate(actualObj);
var isExpectationDate = isDate(expectationObj);
if (isActualDate || isExpectationDate) {
if (!isActualDate || !isExpectationDate || getTime.call(actualObj) !== getTime.call(expectationObj)) {
return false;
}
}
if (actualObj instanceof RegExp && expectationObj instanceof RegExp) {
if (valueToString(actualObj) !== valueToString(expectationObj)) {
return false;
}
}
if (actualObj instanceof Promise && expectationObj instanceof Promise) {
return actualObj === expectationObj;
}
if (actualObj instanceof Error && expectationObj instanceof Error) {
return actualObj === expectationObj;
}
var actualClass = getClass(actualObj);
var expectationClass = getClass(expectationObj);
var actualKeys = getEnumerableStringKeys(actualObj);
var expectationKeys = getEnumerableStringKeys(expectationObj);
var actualName = className(actualObj);
var expectationName = className(expectationObj);
var expectationSymbols = typeOf(getOwnPropertySymbols) === "function" ? getOwnPropertySymbols(expectationObj) : (
/* c8 ignore next: cannot collect coverage for engine that doesn't support Symbol */
[]
);
var expectationKeysAndSymbols = concat(
expectationKeys,
expectationSymbols
);
if (isArguments(actualObj) || isArguments(expectationObj)) {
if (actualObj.length !== expectationObj.length) {
return false;
}
} else {
if (actualType !== expectationType || actualClass !== expectationClass || actualKeys.length !== expectationKeys.length || !hasAllEnumerableStringKeys(actualKeys, expectationKeys) || !hasAllEnumerableStringKeys(expectationKeys, actualKeys) || actualName && expectationName && actualName !== expectationName) {
return false;
}
}
if (isSet(actualObj) || isSet(expectationObj)) {
if (!isSet(actualObj) || !isSet(expectationObj) || actualObj.size !== expectationObj.size) {
return false;
}
return isSubset(actualObj, expectationObj, deepEqual);
}
if (isMap(actualObj) || isMap(expectationObj)) {
if (!isMap(actualObj) || !isMap(expectationObj) || actualObj.size !== expectationObj.size) {
return false;
}
var mapsDeeplyEqual = true;
mapForEach(actualObj, function(value, key) {
mapsDeeplyEqual = mapsDeeplyEqual && deepEqualCyclic(value, expectationObj.get(key));
});
return mapsDeeplyEqual;
}
if (typeof actualObj.jquery === "string" && typeof actualObj.is === "function") {
return actualObj.is(expectationObj);
}
var isActualNonArrayIterable = isIterable(actualObj) && !isArrayType(actualObj) && !isArguments(actualObj);
var isExpectationNonArrayIterable = isIterable(expectationObj) && !isArrayType(expectationObj) && !isArguments(expectationObj);
if (isActualNonArrayIterable || isExpectationNonArrayIterable) {
var actualArray = Array.from(actualObj);
var expectationArray = Array.from(expectationObj);
if (actualArray.length !== expectationArray.length) {
return false;
}
var arrayDeeplyEquals = true;
every(actualArray, function(key) {
arrayDeeplyEquals = arrayDeeplyEquals && deepEqualCyclic(actualArray[key], expectationArray[key]);
});
return arrayDeeplyEquals;
}
return every(expectationKeysAndSymbols, function(key) {
var actualValue = actualObj[key];
var expectationValue = expectationObj[key];
var actualObject = isObject(actualValue);
var expectationObject = isObject(expectationValue);
var actualIndex = actualObject ? indexOf(actualObjects, actualValue) : -1;
var expectationIndex = expectationObject ? indexOf(expectationObjects, expectationValue) : -1;
var newActualPath = actualIndex !== -1 ? actualPaths[actualIndex] : `${actualPath}[${JSON.stringify(key)}]`;
var newExpectationPath = expectationIndex !== -1 ? expectationPaths[expectationIndex] : `${expectationPath}[${JSON.stringify(key)}]`;
var combinedPath = newActualPath + newExpectationPath;
if (compared[combinedPath]) {
return true;
}
if (actualIndex === -1 && actualObject) {
push(actualObjects, actualValue);
push(actualPaths, newActualPath);
}
if (expectationIndex === -1 && expectationObject) {
push(expectationObjects, expectationValue);
push(expectationPaths, newExpectationPath);
}
if (actualObject && expectationObject) {
compared[combinedPath] = true;
}
return deepEqual(
actualValue,
expectationValue,
newActualPath,
newExpectationPath
);
});
})(actual, expectation, "$1", "$2");
}
deepEqualCyclic.use = function(match) {
return function deepEqual(a, b) {
return deepEqualCyclic(a, b, match);
};
};
module2.exports = deepEqualCyclic;
}
});
// node_modules/@sinonjs/samsam/lib/iterable-to-string.js
var require_iterable_to_string = __commonJS({
"node_modules/@sinonjs/samsam/lib/iterable-to-string.js"(exports2, module2) {
"use strict";
var slice = require_lib().prototypes.string.slice;
var typeOf = require_lib().typeOf;
var