Impressum sinon-7.2.7.js
Sprache: JAVA
|
|
/* Sinon.JS 7.2.7, 2019-03-04, @license BSD-3 */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.sinon = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
var behavior = require( "./sinon/behavior");
var createSandbox = require( "./sinon/create-sandbox");
var deprecated = require( "./sinon/util/core/deprecated");
var extend = require( "./sinon/util/core/extend");
var fakeTimers = require( "./sinon/util/fake-timers");
var format = require( "./sinon/util/core/format");
var nise = require( "nise");
var Sandbox = require( "./sinon/sandbox");
var stub = require( "./sinon/stub");
var apiMethods = {
createSandbox: createSandbox,
assert: require( "./sinon/assert"),
match: require( "@sinonjs/samsam").createMatcher,
spyCall: require( "./sinon/call"),
expectation: require( "./sinon/mock-expectation"),
createStubInstance: require( "./sinon/stub").createStubInstance,
defaultConfig: require( "./sinon/util/core/default-config"),
setFormatter: format.setFormatter,
// fake timers
timers: fakeTimers.timers,
// fake XHR
xhr: nise.fakeXhr.xhr,
FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest,
// fake server
fakeServer: nise.fakeServer,
fakeServerWithClock: nise.fakeServerWithClock,
createFakeServer: nise.fakeServer.create.bind(nise.fakeServer),
createFakeServerWithClock: nise.fakeServerWithClock.create.bind(nise.fakeServerWi thClock),
addBehavior: function(name, fn) {
behavior.addBehavior(stub, name, fn);
}
};
var legacySandboxAPI = {
sandbox: {
create: deprecated.wrap(
createSandbox,
// eslint-disable-next-line max-len
"`sandbox.create()` is deprecated. Use default sandbox at `sinon.sandbox` or create new sandboxes with `sinon.createSandbox()`"
)
}
};
var sandbox = new Sandbox();
var api = extend(sandbox, legacySandboxAPI, apiMethods);
module.exports = api;
},{"./sinon/assert":2,"./sinon/behavior":3,"./sinon/call":4,"./sinon/create-sandbox":7,"./sinon/mock-expectation":10,"./sinon/sandbox":12,"./sinon/stub":16,"./sinon/util/core/default-config":18,"./sinon/util/core/deprecated":19,"./sinon/util/core/extend":21,"./sinon/util/core/format":22,"./sinon/util/fake-timers":34,"@sinonjs/samsam":65,"nise":85}],2:[function(require,module,exports){
(function (global){
"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 format = require("./util/core/format");
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;
var arraySlice = arrayProto.slice;
var concat = arrayProto.concat;
var forEach = arrayProto.forEach;
var join = arrayProto.join;
var splice = arrayProto.splice;
var assert;
function verifyIsStub() {
var args = arraySlice(arguments);
forEach(args, function(method) {
if (!method) {
assert.fail("fake is not a spy");
}
if (method.proxy && method.proxy.isSinonProxy) {
verifyIsStub(method.proxy);
} else {
if (typeof method !== "function") {
assert.fail(method + " is not a function");
}
if (typeof method.getCall !== "function") {
assert.fail(method + " is not stubbed");
}
}
});
}
function verifyIsValidAssertion(assertionMethod, assertionArgs) {
switch (assertionMethod) {
case "notCalled":
case "called":
case "calledOnce":
case "calledTwice":
case "calledThrice":
if (assertionArgs.length !== 0) {
assert.fail(
assertionMethod +
" takes 1 argument but was called with " +
(assertionArgs.length + 1) +
" arguments"
);
}
break;
default:
break;
}
}
function failAssertion(object, msg) {
var obj = object || global;
var failMethod = obj.fail || assert.fail;
failMethod.call(obj, msg);
}
function mirrorPropAsAssertion(name, method, message) {
var msg = message;
var meth = method;
if (arguments.length === 2) {
msg = method;
meth = name;
}
assert[name] = function(fake) {
verifyIsStub(fake);
var args = arraySlice(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof meth === "function") {
failed = !meth(fake);
} else {
failed = typeof fake[meth] === "function" ? !fake[meth].apply(fake, args) : !fake[meth];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, concat([msg], args)));
} else {
assert.pass(name);
}
};
}
function exposedName(prefix, prop) {
return !prefix || /^fail/.test(prop) ? prop : prefix + stringSlice(prop, 0, 1).toUpperCase() + 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);
if (method.callCount !== count) {
var 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 = " + format(expectation),
" actual = " + format(actual)
];
failAssertion(this, join(formatted, "\n"));
}
}
};
mirrorPropAsAssertion("called", "expected %n to have been called at least once but was never called");
mirrorPropAsAssertion(
"notCalled",
function(spy) {
return !spy.called;
},
"expected %n to not have been called but was called %c%C"
);
mirrorPropAsAssertion("calledOnce", "expected %n to be called once but was called %c%C");
mirrorPropAsAssertion("calledTwice", "expected %n to be called twice but was called %c%C");
mirrorPropAsAssertion("calledThrice", "expected %n to be called thrice but was called %c%C");
mirrorPropAsAssertion("calledOn", "expected %n to be called with %1 as this but was called with %t");
mirrorPropAsAssertion("alwaysCalledOn", "expected %n to always be called with %1 as this but was called with %t");
mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new");
mirrorPropAsAssertion("alwaysCalledWithNew", "expected %n to always be called with new");
mirrorPropAsAssertion("calledWith", "expected %n to be called with arguments %D");
mirrorPropAsAssertion("calledWithMatch", "expected %n to be called with match %D");
mirrorPropAsAssertion("alwaysCalledWith", "expected %n to always be called with arguments %D");
mirrorPropAsAssertion("alwaysCalledWithMatch", "expected %n to always be called with match %D");
mirrorPropAsAssertion("calledWithExactly", "expected %n to be called with exact arguments %D");
mirrorPropAsAssertion("alwaysCalledWithExactly", "expected %n to always be called with exact arguments %D");
mirrorPropAsAssertion("neverCalledWith", "expected %n to never be called with arguments %*%C");
mirrorPropAsAssertion("neverCalledWithMatch", "expected %n to never be called with match %*%C");
mirrorPropAsAssertion("threw", "%n did not throw exception%C");
mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C");
module.exports = assert;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./util/core/format":22,"./util/core/times-in-words":30,"@sinonjs/commons":39,"@sinonjs/samsam":65}],3:[function(require,module,exports){
"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");
var concat = arrayProto.concat;
var join = arrayProto.join;
var reverse = arrayProto.reverse;
var slice = arrayProto.slice;
var useLeftMostCallback = -1;
var useRightMostCallback = -2;
function getCallback(behavior, args) {
var callArgAt = behavior.callArgAt;
if (callArgAt >= 0) {
return args[callArgAt];
}
var argumentList;
if (callArgAt === useLeftMostCallback) {
argumentList = args;
}
if (callArgAt === useRightMostCallback) {
argumentList = reverse(slice(args));
}
var callArgProp = behavior.callArgProp;
for (var 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(behavior, func, args) {
if (behavior.callArgAt < 0) {
var msg;
if (behavior.callArgProp) {
msg =
functionName(behavior.stub) +
" expected to yield to '" +
valueToString(behavior.callArgProp) +
"', but no object with such a property was passed.";
} else {
msg = functionName(behavior.stub) + " expected to yield, but no callback was passed.";
}
if (args.length > 0) {
msg += " Received [" + join(args, ", ") + "]";
}
return msg;
}
return "argument at index " + behavior.callArgAt + " is not a function: " + func;
}
function ensureArgs(name, behavior, args) {
// map function name to internal property
// callsArg => callArgAt
var property = name.replace(/sArg/, "ArgAt");
var index = behavior[property];
if (index >= args.length) {
throw new TypeError(
name + " failed: " + (index + 1) + " arguments required but only " + args.length + " present"
);
}
}
function callCallback(behavior, args) {
if (typeof behavior.callArgAt === "number") {
ensureArgs("callsArg", behavior, args);
var func = getCallback(behavior, args);
if (typeof func !== "function") {
throw new TypeError(getCallbackError(behavior, func, args));
}
if (behavior.callbackAsync) {
nextTick(function() {
func.apply(behavior.callbackContext, behavior.callbackArguments);
});
} else {
return func.apply(behavior.callbackContext, behavior.callbackArguments);
}
}
return undefined;
}
var proto = {
create: function create(stub) {
var behavior = extend({}, proto);
delete behavior.create;
delete behavior.addBehavior;
delete behavior.createBehavior;
behavior.stub = stub;
if (stub.defaultBehavior && stub.defaultBehavior.promiseLibrary) {
behavior.promiseLibrary = stub.defaultBehavior.promiseLibrary;
}
return behavior;
},
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
);
},
invoke: function invoke(context, args) {
/*
* callCallback (conditionally) calls ensureArgs
*
* Note: callCallback intentionally happens before
* everything else and cannot be moved lower
*/
var returnValue = callCallback(this, args);
if (this.exception) {
throw this.exception;
} else if (this.exceptionCreator) {
this.exception = this.exceptionCreator();
this.exceptionCreator = undefined;
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) {
return this.stub.wrappedMethod.apply(context, args);
} else if (typeof this.returnValue !== "undefined") {
return this.returnValue;
} else if (typeof this.callArgAt === "number") {
return returnValue;
}
return this.returnValue;
},
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(/* arguments */) {
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);
module.exports = extend.nonEnum({}, proto, asyncBehaviors);
},{"./util/core/export-async-behaviors":20,"./util/core/extend":21,"./util/core/next-tick":29,"@sinonjs/commons":39}],4:[function(require,module,exports){
"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 sinonFormat = require("./util/core/format");
var 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;
function throwYieldError(proxy, text, args) {
var msg = functionName(proxy) + text;
if (args.length) {
msg += " Received [" + join(slice(args), ", ") + "]";
}
throw new Error(msg);
}
var callProto = {
calledOn: function calledOn(thisValue) {
if (match.isMatcher(thisValue)) {
return thisValue.test(this.thisValue);
}
return this.thisValue === thisValue;
},
calledWith: function calledWith() {
var self = this;
var calledWithArgs = slice(arguments);
if (calledWithArgs.length > self.args.length) {
return false;
}
return reduce(
calledWithArgs,
function(prev, arg, i) {
return prev && deepEqual(self.args[i], arg);
},
true
);
},
calledWithMatch: function calledWithMatch() {
var self = this;
var calledWithMatchArgs = slice(arguments);
if (calledWithMatchArgs.length > self.args.length) {
return false;
}
return reduce(
calledWithMatchArgs,
function(prev, expectation, i) {
var actual = self.args[i];
return prev && match(expectation).test(actual);
},
true
);
},
calledWithExactly: function calledWithExactly() {
return arguments.length === this.args.length && this.calledWith.apply(this, arguments);
},
notCalledWith: function notCalledWith() {
return !this.calledWith.apply(this, arguments);
},
notCalledWithMatch: function notCalledWithMatch() {
return !this.calledWithMatch.apply(this, arguments);
},
returned: function returned(value) {
return deepEqual(this.returnValue, value);
},
threw: function threw(error) {
if (typeof error === "undefined" || !this.exception) {
return Boolean(this.exception);
}
return this.exception === error || this.exception.name === error;
},
calledWithNew: function calledWithNew() {
return this.proxy.prototype && this.thisValue instanceof this.proxy;
},
calledBefore: function(other) {
return this.callId < other.callId;
},
calledAfter: function(other) {
return this.callId > other.callId;
},
calledImmediatelyBefore: function(other) {
return this.callId === other.callId - 1;
},
calledImmediatelyAfter: function(other) {
return this.callId === other.callId + 1;
},
callArg: function(pos) {
this.ensureArgIsAFunction(pos);
return this.args[pos]();
},
callArgOn: function(pos, thisValue) {
this.ensureArgIsAFunction(pos);
return this.args[pos].apply(thisValue);
},
callArgWith: function(pos) {
return this.callArgOnWith.apply(this, concat([pos, null], slice(arguments, 1)));
},
callArgOnWith: function(pos, thisValue) {
this.ensureArgIsAFunction(pos);
var args = slice(arguments, 2);
return this.args[pos].apply(thisValue, args);
},
throwArg: function(pos) {
if (pos > this.args.length) {
throw new TypeError("Not enough arguments: " + pos + " required but only " + this.args.length + " present");
}
throw this.args[pos];
},
yield: function() {
return this.yieldOn.apply(this, concat([null], slice(arguments, 0)));
},
yieldOn: function(thisValue) {
var args = slice(this.args);
var yieldFn = filter(args, function(arg) {
return typeof arg === "function";
})[0];
if (!yieldFn) {
throwYieldError(this.proxy, " cannot yield since no callback was passed.", args);
}
return yieldFn.apply(thisValue, slice(arguments, 1));
},
yieldTo: function(prop) {
return this.yieldToOn.apply(this, concat([prop, null], slice(arguments, 1)));
},
yieldToOn: function(prop, thisValue) {
var args = slice(this.args);
var yieldArg = filter(args, function(arg) {
return arg && typeof arg[prop] === "function";
})[0];
var yieldFn = yieldArg && yieldArg[prop];
if (!yieldFn) {
throwYieldError(
this.proxy,
" cannot yield to '" + valueToString(prop) + "' since no callback was passed.",
args
);
}
return yieldFn.apply(thisValue, slice(arguments, 2));
},
toString: function() {
var callStr = this.proxy ? String(this.proxy) + "(" : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = map(this.args, function(arg) {
return sinonFormat(arg);
});
callStr = callStr + join(formattedArgs, ", ") + ")";
if (typeof this.returnValue !== "undefined") {
callStr += " => " + sinonFormat(this.returnValue);
}
if (this.exception) {
callStr += " !" + this.exception.name;
if (this.exception.message) {
callStr += "(" + this.exception.message + ")";
}
}
if (this.stack) {
// Omit the error message and the two top stack frames in sinon itself:
callStr += (this.stack.split("\n")[3] || "unknown").replace(/^\s*(?:at\s+|@)?/, " at ");
}
return callStr;
},
ensureArgIsAFunction: function(pos) {
if (typeof this.args[pos] !== "function") {
throw new TypeError(
"Expected argument at position " + pos + " to be a Function, but was " + typeof this.args[pos]
);
}
}
};
Object.defineProperty(callProto, "stack", {
enumerable: true,
configurable: true,
get: function() {
return (this.errorWithCallStack && this.errorWithCallStack.stack) || "";
}
});
callProto.invokeCallback = callProto.yield;
function createSpyCall(spy, thisValue, args, returnValue, exception, id, errorWithCallStack) {
if (typeof id !== "number") {
throw new TypeError("Call id is not a number");
}
var proxyCall = Object.create(callProto);
var lastArg = (args.length > 0 && args[args.length - 1]) || undefined;
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
proxyCall.proxy = spy;
proxyCall.thisValue = thisValue;
proxyCall.args = args;
proxyCall.lastArg = lastArg;
proxyCall.callback = callback;
proxyCall.returnValue = returnValue;
proxyCall.exception = exception;
proxyCall.callId = id;
proxyCall.errorWithCallStack = errorWithCallStack;
return proxyCall;
}
createSpyCall.toString = callProto.toString; // used by mocks
module.exports = createSpyCall;
},{"./util/core/format":22,"@sinonjs/commons":39,"@sinonjs/samsam":65}],5:[function(require,module,exports){
"use strict";
var walk = require("./util/core/walk");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var push = require("@sinonjs/commons").prototypes.array.push;
function collectMethod(methods, object, prop, propOwner) {
if (typeof getPropertyDescriptor(propOwner, prop).value === "function" && hasOwnProperty(object, prop)) {
push(methods, object[prop]);
}
}
// This function returns an array of all the own methods on the passed object
function collectOwnMethods(object) {
var methods = [];
walk(object, collectMethod.bind(null, methods, object));
return methods;
}
module.exports = collectOwnMethods;
},{"./util/core/get-property-descriptor":25,"./util/core/walk":32,"@sinonjs/commons":39}],6:[function(require,module,exports){
"use strict";
var supportsColor = require("supports-color");
function colorize(str, color) {
if (supportsColor.stdout === false) {
return str;
}
return "\x1b[" + color + "m" + str + "\x1b[0m";
}
exports.red = function(str) {
return colorize(str, 31);
};
exports.green = function(str) {
return colorize(str, 32);
};
exports.cyan = function(str) {
return colorize(str, 96);
};
exports.white = function(str) {
return colorize(str, 39);
};
exports.bold = function(str) {
return colorize(str, 1);
};
},{"supports-color":88}],7:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var Sandbox = require("./sandbox");
var forEach = arrayProto.forEach;
var push = arrayProto.push;
function prepareSandboxFromConfig(config) {
var sandbox = new Sandbox();
if (config.useFakeServer) {
if (typeof config.useFakeServer === "object") {
sandbox.serverPrototype = config.useFakeServer;
}
sandbox.useFakeServer();
}
if (config.useFakeTimers) {
if (typeof config.useFakeTimers === "object") {
sandbox.useFakeTimers(config.useFakeTimers);
} else {
sandbox.useFakeTimers();
}
}
return sandbox;
}
function exposeValue(sandbox, config, key, value) {
if (!value) {
return;
}
if (config.injectInto && !(key in config.injectInto)) {
config.injectInto[key] = value;
push(sandbox.injectedKeys, key);
} else {
push(sandbox.args, value);
}
}
function createSandbox(config) {
if (!config) {
return new Sandbox();
}
var configuredSandbox = prepareSandboxFromConfig(config);
configuredSandbox.args = configuredSandbox.args || [];
configuredSandbox.injectedKeys = [];
configuredSandbox.injectInto = config.injectInto;
var exposed = configuredSandbox.inject({});
if (config.properties) {
forEach(config.properties, function(prop) {
var value = exposed[prop] || (prop === "sandbox" && configuredSandbox);
exposeValue(configuredSandbox, config, prop, value);
});
} else {
exposeValue(configuredSandbox, config, "sandbox");
}
return configuredSandbox;
}
module.exports = createSandbox;
},{"./sandbox":12,"@sinonjs/commons":39}],8:[function(require,module,exports){
"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");
var slice = arrayProto.slice;
var useLeftMostCallback = -1;
var 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 || "");
newException.name = error;
return newException;
};
} else if (!error) {
fake.exceptionCreator = function() {
return new Error("Error");
};
} else {
fake.exception = error;
}
}
var defaultBehaviors = {
callsFake: function callsFake(fake, fn) {
fake.fakeFn = fn;
},
callsArg: function callsArg(fake, index) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = index;
fake.callbackArguments = [];
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
callsArgOn: function callsArgOn(fake, index, context) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = index;
fake.callbackArguments = [];
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
callsArgWith: function callsArgWith(fake, index) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = index;
fake.callbackArguments = slice(arguments, 2);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
callsArgOnWith: function callsArgWith(fake, index, context) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = index;
fake.callbackArguments = slice(arguments, 3);
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
usingPromise: function usingPromise(fake, promiseLibrary) {
fake.promiseLibrary = promiseLibrary;
},
yields: function(fake) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
yieldsRight: function(fake) {
fake.callArgAt = useRightMostCallback;
fake.callbackArguments = slice(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
yieldsOn: function(fake, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 2);
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
},
yieldsTo: function(fake, prop) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 2);
fake.callbackContext = undefined;
fake.callArgProp = prop;
fake.callbackAsync = false;
},
yieldsToOn: function(fake, prop, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice(arguments, 3);
fake.callbackContext = context;
fake.callArgProp = prop;
fake.callbackAsync = false;
},
throws: throwsException,
throwsException: throwsException,
returns: function returns(fake, value) {
fake.returnValue = value;
fake.resolve = false;
fake.reject = false;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
},
returnsArg: function returnsArg(fake, index) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.returnArgAt = index;
},
throwsArg: function throwsArg(fake, index) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.throwArgAt = index;
},
returnsThis: function returnsThis(fake) {
fake.returnThis = true;
},
resolves: function resolves(fake, value) {
fake.returnValue = value;
fake.resolve = true;
fake.resolveThis = false;
fake.reject = false;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
},
resolvesArg: function resolvesArg(fake, index) {
if (typeof index !== "number") {
throw new TypeError("argument index is not number");
}
fake.resolveArgAt = index;
fake.returnValue = undefined;
fake.resolve = true;
fake.resolveThis = false;
fake.reject = false;
fake.returnValueDefined = false;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
},
rejects: function rejects(fake, error, message) {
var reason;
if (typeof error === "string") {
reason = new Error(message || "");
reason.name = error;
} else if (!error) {
reason = new Error("Error");
} else {
reason = error;
}
fake.returnValue = reason;
fake.resolve = false;
fake.resolveThis = false;
fake.reject = true;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
return fake;
},
resolvesThis: function resolvesThis(fake) {
fake.returnValue = undefined;
fake.resolve = false;
fake.resolveThis = true;
fake.reject = false;
fake.returnValueDefined = false;
fake.exception = undefined;
fake.exceptionCreator = undefined;
fake.fakeFn = undefined;
},
callThrough: function callThrough(fake) {
fake.callsThrough = true;
},
get: function get(fake, getterFunction) {
var rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
get: getterFunction,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
});
return fake;
},
set: function set(fake, setterFunction) {
var rootStub = fake.stub || fake;
Object.defineProperty(
rootStub.rootObj,
rootStub.propName,
// eslint-disable-next-line accessor-pairs
{
set: setterFunction,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
}
);
return fake;
},
value: function value(fake, newVal) {
var rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
value: newVal,
enumerable: true,
configurable: isPropertyConfigurable(rootStub.rootObj, rootStub.propName)
});
return fake;
}
};
var asyncBehaviors = exportAsyncBehaviors(defaultBehaviors);
module.exports = extend({}, defaultBehaviors, asyncBehaviors);
},{"./util/core/export-async-behaviors":20,"./util/core/extend":21,"./util/core/is-property-configurable":28,"@sinonjs/commons":39}],9:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var spy = require("./spy");
var nextTick = require("./util/core/next-tick");
var forEach = arrayProto.forEach;
var slice = arrayProto.slice;
function getError(value) {
return value instanceof Error ? value : new Error(value);
}
function cleanProxy(f) {
var undesirableProperties = [
"instantiateFake",
"callArg",
"callArgOn",
"callArgOnWith",
"callArgWith",
"invokeCallback",
"throwArg",
"withArgs",
"yield",
"yieldOn",
"yieldTo",
"yieldToOn"
];
forEach(undesirableProperties, function(key) {
delete f[key];
});
return f;
}
var uuid = 0;
function wrapFunc(f) {
var fakeInstance = function() {
var lastArg = arguments.length > 0 ? arguments[arguments.length - 1] : undefined;
var callback = lastArg && typeof lastArg === "function" ? lastArg : undefined;
/* eslint-disable no-use-before-define */
p.lastArg = lastArg;
p.callback = callback;
/* eslint-enable no-use-before-define */
return f && f.apply(this, arguments);
};
var p = cleanProxy(spy(fakeInstance));
p.displayName = "fake";
p.id = "fake#" + uuid++;
return p;
}
function fake(f) {
if (arguments.length > 0 && typeof f !== "function") {
throw new TypeError("Expected f argument to be a Function");
}
return wrapFunc(f);
}
fake.returns = function returns(value) {
function f() {
return value;
}
return wrapFunc(f);
};
fake.throws = function throws(value) {
function f() {
throw getError(value);
}
return wrapFunc(f);
};
fake.resolves = function resolves(value) {
function f() {
return Promise.resolve(value);
}
return wrapFunc(f);
};
fake.rejects = function rejects(value) {
function f() {
return Promise.reject(getError(value));
}
return wrapFunc(f);
};
function yieldInternal(async, values) {
function f() {
var callback = arguments[arguments.length - 1];
if (typeof callback !== "function") {
throw new TypeError("Expected last argument to be a function");
}
if (async) {
nextTick(function() {
callback.apply(null, values);
});
} else {
callback.apply(null, values);
}
}
return wrapFunc(f);
}
fake.yields = function yields() {
return yieldInternal(false, slice(arguments));
};
fake.yieldsAsync = function yieldsAsync() {
return yieldInternal(true, slice(arguments));
};
module.exports = fake;
},{"./spy":14,"./util/core/next-tick":29,"@sinonjs/commons":39}],10:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var spyInvoke = require("./spy").invoke;
var spyCallToString = require("./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 format = require("./util/core/format");
var valueToString = require("@sinonjs/commons").valueToString;
var every = arrayProto.every;
var forEach = arrayProto.forEach;
var push = arrayProto.push;
var slice = arrayProto.slice;
function callCountInWords(callCount) {
if (callCount === 0) {
return "never called";
}
return "called " + timesInWords(callCount);
}
function expectedCallCountInWords(expectation) {
var min = expectation.minCalls;
var max = expectation.maxCalls;
if (typeof min === "number" && typeof max === "number") {
var str = timesInWords(min);
if (min !== max) {
str = "at least " + str + " and at most " + timesInWords(max);
}
return str;
}
if (typeof min === "number") {
return "at least " + timesInWords(min);
}
return "at most " + timesInWords(max);
}
function receivedMinCalls(expectation) {
var hasMinLimit = typeof expectation.minCalls === "number";
return !hasMinLimit || expectation.callCount >= expectation.minCalls;
}
function receivedMaxCalls(expectation) {
if (typeof expectation.maxCalls !== "number") {
return false;
}
return expectation.callCount === expectation.maxCalls;
}
function verifyMatcher(possibleMatcher, arg) {
var isMatcher = match.isMatcher(possibleMatcher);
return (isMatcher && possibleMatcher.test(arg)) || true;
}
var mockExpectation = {
minCalls: 1,
maxCalls: 1,
create: function create(methodName) {
var expectation = extend.nonEnum(stub.create(), mockExpectation);
delete expectation.create;
expectation.method = methodName;
return expectation;
},
invoke: function invoke(func, thisValue, args) {
this.verifyCallAllowed(thisValue, args);
return spyInvoke.apply(this, arguments);
},
atLeast: function atLeast(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not number");
}
if (!this.limitsSet) {
this.maxCalls = null;
this.limitsSet = true;
}
this.minCalls = num;
return this;
},
atMost: function atMost(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not number");
}
if (!this.limitsSet) {
this.minCalls = null;
this.limitsSet = true;
}
this.maxCalls = num;
return this;
},
never: function never() {
return this.exactly(0);
},
once: function once() {
return this.exactly(1);
},
twice: function twice() {
return this.exactly(2);
},
thrice: function thrice() {
return this.exactly(3);
},
exactly: function exactly(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not a number");
}
this.atLeast(num);
return this.atMost(num);
},
met: function met() {
return !this.failed && receivedMinCalls(this);
},
verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
var expectedArguments = this.expectedArguments;
if (receivedMaxCalls(this)) {
this.failed = true;
mockExpectation.fail(this.method + " already called " + timesInWords(this.maxCalls));
}
if ("expectedThis" in this && this.expectedThis !== thisValue) {
mockExpectation.fail(
this.method +
" called with " +
valueToString(thisValue) +
" as thisValue, expected " +
valueToString(this.expectedThis)
);
}
if (!("expectedArguments" in this)) {
return;
}
if (!args) {
mockExpectation.fail(this.method + " received no arguments, expected " + format(expectedArguments));
}
if (args.length < expectedArguments.length) {
mockExpectation.fail(
this.method +
" received too few arguments (" +
format(args) +
"), expected " +
format(expectedArguments)
);
}
if (this.expectsExactArgCount && args.length !== expectedArguments.length) {
mockExpectation.fail(
this.method +
" received too many arguments (" +
format(args) +
"), expected " +
format(expectedArguments)
);
}
forEach(
expectedArguments,
function(expectedArgument, i) {
if (!verifyMatcher(expectedArgument, args[i])) {
mockExpectation.fail(
this.method +
" received wrong arguments " +
format(args) +
", didn't match " +
String(expectedArguments)
);
}
if (!deepEqual(args[i], expectedArgument)) {
mockExpectation.fail(
this.method +
" received wrong arguments " +
format(args) +
", expected " +
format(expectedArguments)
);
}
},
this
);
},
allowsCall: function allowsCall(thisValue, args) {
var expectedArguments = this.expectedArguments;
if (this.met() && receivedMaxCalls(this)) {
return false;
}
if ("expectedThis" in this && this.expectedThis !== thisValue) {
return false;
}
if (!("expectedArguments" in this)) {
return true;
}
// eslint-disable-next-line no-underscore-dangle
var _args = args || [];
if (_args.length < expectedArguments.length) {
return false;
}
if (this.expectsExactArgCount && _args.length !== expectedArguments.length) {
return false;
}
return every(expectedArguments, function(expectedArgument, i) {
if (!verifyMatcher(expectedArgument, _args[i])) {
return false;
}
if (!deepEqual(_args[i], expectedArgument)) {
return false;
}
return true;
});
},
withArgs: function withArgs() {
this.expectedArguments = slice(arguments);
return this;
},
withExactArgs: function withExactArgs() {
this.withArgs.apply(this, arguments);
this.expectsExactArgCount = true;
return this;
},
on: function on(thisValue) {
this.expectedThis = thisValue;
return this;
},
toString: function() {
var args = slice(this.expectedArguments || []);
if (!this.expectsExactArgCount) {
push(args, "[...]");
}
var callStr = spyCallToString.call({
proxy: this.method || "anonymous mock expectation",
args: args
});
var message = callStr.replace(", [...", "[, ...") + " " + expectedCallCountInWords(this);
if (this.met()) {
return "Expectation met: " + message;
}
return "Expected " + message + " (" + callCountInWords(this.callCount) + ")";
},
verify: function verify() {
if (!this.met()) {
mockExpectation.fail(String(this));
} else {
mockExpectation.pass(String(this));
}
return true;
},
pass: function pass(message) {
assert.pass(message);
},
fail: function fail(message) {
var exception = new Error(message);
exception.name = "ExpectationError";
throw exception;
}
};
module.exports = mockExpectation;
},{"./assert":2,"./call":4,"./spy":14,"./stub":16,"./util/core/extend":21,"./util/core/format":22,"./util/core/times-in-words":30,"@sinonjs/commons":39,"@sinonjs/samsam":65}],11:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var mockExpectation = require("./mock-expectation");
var spyCallToString = require("./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");
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;
function mock(object) {
if (!object || typeof object === "string") {
return mockExpectation.create(object ? object : "Anonymous mock");
}
return mock.create(object);
}
function each(collection, callback) {
var col = collection || [];
forEach(col, callback);
}
function arrayEquals(arr1, arr2, compareLength) {
if (compareLength && arr1.length !== arr2.length) {
return false;
}
return every(arr1, function(element, i) {
return deepEqual(arr2[i], element);
});
}
extend(mock, {
create: function create(object) {
if (!object) {
throw new TypeError("object is null");
}
var mockObject = extend.nonEnum({}, mock, { object: object });
delete mockObject.create;
return mockObject;
},
expects: function expects(method) {
if (!method) {
throw new TypeError("method is falsy");
}
if (!this.expectations) {
this.expectations = {};
this.proxies = [];
this.failures = [];
}
if (!this.expectations[method]) {
this.expectations[method] = [];
var mockObject = this;
wrapMethod(this.object, method, function() {
return mockObject.invokeMethod(method, this, arguments);
});
push(this.proxies, method);
}
var expectation = mockExpectation.create(method);
extend.nonEnum(expectation, this.object[method]);
push(this.expectations[method], expectation);
usePromiseLibrary(this.promiseLibrary, expectation);
return expectation;
},
restore: function restore() {
var object = this.object;
each(this.proxies, function(proxy) {
if (typeof object[proxy].restore === "function") {
object[proxy].restore();
}
});
},
verify: function verify() {
var expectations = this.expectations || {};
var messages = this.failures ? slice(this.failures) : [];
var met = [];
each(this.proxies, function(proxy) {
each(expectations[proxy], function(expectation) {
if (!expectation.met()) {
push(messages, String(expectation));
} else {
push(met, String(expectation));
}
});
});
this.restore();
if (messages.length > 0) {
mockExpectation.fail(join(concat(messages, met), "\n"));
} else if (met.length > 0) {
mockExpectation.pass(join(concat(messages, met), "\n"));
}
return true;
},
usingPromise: function usingPromise(promiseLibrary) {
this.promiseLibrary = promiseLibrary;
return this;
},
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 = this.expectations && this.expectations[method] ? this.expectations[method] : [];
var currentArgs = args || [];
var available;
var expectationsWithMatchingArgs = filter(expectations, function(expectation) {
var expectedArgs = expectation.expectedArguments || [];
return arrayEquals(expectedArgs, currentArgs, expectation.expectsExactArgCount);
});
var expectationsToApply = filter(expectationsWithMatchingArgs, function(expectation) {
return !expectation.met() && expectation.allowsCall(thisValue, args);
});
if (expectationsToApply.length > 0) {
return expectationsToApply[0].apply(thisValue, args);
}
var messages = [];
var exhausted = 0;
forEach(expectationsWithMatchingArgs, function(expectation) {
if (expectation.allowsCall(thisValue, args)) {
available = available || expectation;
} else {
exhausted += 1;
}
});
if (available && exhausted === 0) {
return available.apply(thisValue, args);
}
forEach(expectations, function(expectation) {
push(messages, " " + String(expectation));
});
unshift(
messages,
"Unexpected call: " +
spyCallToString.call({
proxy: method,
args: args
})
);
var err = new Error();
if (!err.stack) {
// PhantomJS does not serialize the stack trace until the error has been thrown
try {
throw err;
} catch (e) {
/* empty */
}
}
push(
this.failures,
"Unexpected call: " +
spyCallToString.call({
proxy: method,
args: args,
stack: err.stack
})
);
mockExpectation.fail(join(messages, "\n"));
}
});
module.exports = mock;
},{"./call":4,"./mock-expectation":10,"./util/core/extend":21,"./util/core/use-promise-library":31,"./util/core/wrap-method":33,"@sinonjs/commons":39,"@sinonjs/samsam":65}],12:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var collectOwnMethods = require("./collect-own-methods");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var isEsModule = require("./util/core/is-es-module");
var isPropertyConfigurable = require("./util/core/is-property-configurable");
var isNonExistentOwnProperty = require("./util/core/is-non-existent-own-property");
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");
var filter = arrayProto.filter;
var forEach = arrayProto.filter;
var push = arrayProto.push;
var reverse = arrayProto.reverse;
function applyOnEach(fakes, method) {
var matchingFakes = filter(fakes, function(fake) {
return typeof fake[method] === "function";
});
forEach(matchingFakes, function(fake) {
fake[method]();
});
}
function Sandbox() {
var sandbox = this;
var collection = [];
var fakeRestorers = [];
var promiseLib;
sandbox.serverPrototype = fakeServer;
// this is for testing only
sandbox.getFakes = function getFakes() {
return collection;
};
// this is for testing only
sandbox.getRestorers = function() {
return fakeRestorers;
};
sandbox.createStubInstance = function createStubInstance(constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return this.stub(Object.create(constructor.prototype));
};
sandbox.inject = function inject(obj) {
obj.spy = function() {
return sandbox.spy.apply(null, arguments);
};
obj.stub = function() {
return sandbox.stub.apply(null, arguments);
};
obj.mock = function() {
return sandbox.mock.apply(null, arguments);
};
if (sandbox.clock) {
obj.clock = sandbox.clock;
}
if (sandbox.server) {
obj.server = sandbox.server;
obj.requests = sandbox.server.requests;
}
obj.match = match;
return obj;
};
sandbox.mock = function mock() {
var m = sinonMock.apply(null, arguments);
push(collection, m);
usePromiseLibrary(promiseLib, m);
return m;
};
sandbox.reset = function reset() {
applyOnEach(collection, "reset");
applyOnEach(collection, "resetHistory");
};
sandbox.resetBehavior = function resetBehavior() {
applyOnEach(collection, "resetBehavior");
};
sandbox.resetHistory = function resetHistory() {
function privateResetHistory(f) {
var method = f.resetHistory || f.reset;
if (method) {
method.call(f);
}
}
forEach(collection, function(fake) {
if (typeof fake === "function") {
privateResetHistory(fake);
return;
}
var methods = [];
if (fake.get) {
push(methods, fake.get);
}
if (fake.set) {
push(methods, fake.set);
}
forEach(methods, privateResetHistory);
});
};
sandbox.restore = function restore() {
if (arguments.length) {
throw new Error("sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()");
}
reverse(collection);
applyOnEach(collection, "restore");
collection = [];
forEach(fakeRestorers, function(restorer) {
restorer();
});
fakeRestorers = [];
sandbox.restoreContext();
};
sandbox.restoreContext = function restoreContext() {
var injectedKeys = sandbox.injectedKeys;
var injectInto = sandbox.injectInto;
if (!injectedKeys) {
return;
}
forEach(injectedKeys, function(injectedKey) {
delete injectInto[injectedKey];
});
injectedKeys = [];
};
function getFakeRestorer(object, property) {
var descriptor = getPropertyDescriptor(object, property);
function restorer() {
Object.defineProperty(object, property, descriptor);
}
restorer.object = object;
restorer.property = property;
return restorer;
}
function verifyNotReplaced(object, property) {
forEach(fakeRestorers, function(fakeRestorer) {
if (fakeRestorer.object === object && fakeRestorer.property === property) {
throw new TypeError("Attempted to replace " + property + " which is already replaced");
}
});
}
sandbox.replace = function replace(object, property, replacement) {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent own property " + valueToString(property));
}
if (typeof replacement === "undefined") {
throw new TypeError("Expected replacement argument to be defined");
}
if (typeof descriptor.get === "function") {
throw new Error("Use sandbox.replaceGetter for replacing getters");
}
if (typeof descriptor.set === "function") {
throw new Error("Use sandbox.replaceSetter for replacing setters");
}
if (typeof object[property] !== typeof replacement) {
throw new TypeError("Cannot replace " + typeof object[property] + " with " + typeof replacement);
}
verifyNotReplaced(object, property);
// store a function for restoring the replaced property
push(fakeRestorers, getFakeRestorer(object, property));
object[property] = replacement;
return replacement;
};
sandbox.replaceGetter = function replaceGetter(object, property, replacement) {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent own property " + valueToString(property));
}
if (typeof replacement !== "function") {
throw new TypeError("Expected replacement argument to be a function");
}
if (typeof descriptor.get !== "function") {
throw new Error("`object.property` is not a getter");
}
verifyNotReplaced(object, property);
// store a function for restoring the replaced property
push(fakeRestorers, getFakeRestorer(object, property));
Object.defineProperty(object, property, {
get: replacement,
configurable: isPropertyConfigurable(object, property)
});
return replacement;
};
sandbox.replaceSetter = function replaceSetter(object, property, replacement) {
var descriptor = getPropertyDescriptor(object, property);
if (typeof descriptor === "undefined") {
throw new TypeError("Cannot replace non-existent own property " + valueToString(property));
}
if (typeof replacement !== "function") {
throw new TypeError("Expected replacement argument to be a function");
}
if (typeof descriptor.set !== "function") {
throw new Error("`object.property` is not a setter");
}
verifyNotReplaced(object, property);
// store a function for restoring the replaced property
push(fakeRestorers, getFakeRestorer(object, property));
// eslint-disable-next-line accessor-pairs
Object.defineProperty(object, property, {
set: replacement,
configurable: isPropertyConfigurable(object, property)
});
return replacement;
};
sandbox.spy = function spy() {
var s = sinonSpy.apply(sinonSpy, arguments);
push(collection, s);
return s;
};
sandbox.stub = function stub(object, property) {
if (isEsModule(object)) {
throw new TypeError("ES Modules cannot be stubbed");
}
if (isNonExistentOwnProperty(object, property)) {
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
}
var stubbed = sinonStub.apply(null, arguments);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
if (isStubbingEntireObject) {
var ownMethods = collectOwnMethods(stubbed);
forEach(ownMethods, function(method) {
push(collection, method);
});
usePromiseLibrary(promiseLib, ownMethods);
} else {
push(collection, stubbed);
usePromiseLibrary(promiseLib, stubbed);
}
return stubbed;
};
// eslint-disable-next-line no-unused-vars
sandbox.fake = function fake(f) {
var s = sinonFake.apply(sinonFake, arguments);
push(collection, s);
return s;
};
forEach(Object.keys(sinonFake), function(key) {
var fakeBehavior = sinonFake[key];
if (typeof fakeBehavior === "function") {
sandbox.fake[key] = function() {
var s = fakeBehavior.apply(fakeBehavior, arguments);
push(collection, s);
return s;
};
}
});
sandbox.useFakeTimers = function useFakeTimers(args) {
var clock = sinonClock.useFakeTimers.call(null, args);
sandbox.clock = clock;
push(collection, clock);
return clock;
};
sandbox.verify = function verify() {
applyOnEach(collection, "verify");
};
sandbox.verifyAndRestore = function verifyAndRestore() {
var exception;
try {
sandbox.verify();
} catch (e) {
exception = e;
}
sandbox.restore();
if (exception) {
throw exception;
}
};
sandbox.useFakeServer = function useFakeServer() {
var proto = sandbox.serverPrototype || fakeServer;
if (!proto || !proto.create) {
return null;
}
sandbox.server = proto.create();
push(collection, sandbox.server);
return sandbox.server;
};
sandbox.useFakeXMLHttpRequest = function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
push(collection, xhr);
return xhr;
};
sandbox.usingPromise = function usingPromise(promiseLibrary) {
promiseLib = promiseLibrary;
collection.promiseLibrary = promiseLibrary;
return sandbox;
};
}
Sandbox.prototype.assert = sinonAssert;
Sandbox.prototype.match = match;
module.exports = Sandbox;
},{"./assert":2,"./collect-own-methods":5,"./fake":9,"./mock":11,"./spy":14,"./stub":16,"./util/core/get-property-descriptor":25,"./util/core/is-es-module":26,"./util/core/is-non-existent-own-property":27,"./util/core/is-property-configurable":28,"./util/core/use-promise-library":31,"./util/fake-timers":34,"@sinonjs/commons":39,"@sinonjs/samsam":65,"nise":85}],13:[function(require,module,exports){
"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 sinonFormat = require("./util/core/format");
var jsDiff = require("diff");
var join = arrayProto.join;
var map = arrayProto.map;
var push = arrayProto.push;
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
var calledArgumentMessage = calledArgMessage;
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
if (calledArgumentMessage) {
calledArgumentMessage = color.green(calledArgumentMessage);
}
}
return calledArgumentMessage + " " + matcher.message;
}
function colorDiffText(diff) {
var objects = map(diff, function(part) {
var text = part.value;
if (part.added) {
text = color.green(text);
} else if (part.removed) {
text = color.red(text);
}
if (diff.length === 2) {
text += " "; // format simple diffs
}
return text;
});
return join(objects, "");
}
module.exports = {
c: function(spyInstance) {
return timesInWords(spyInstance.callCount);
},
n: function(spyInstance) {
// eslint-disable-next-line local-rules/no-prototype-methods
return spyInstance.toString();
},
D: function(spyInstance, args) {
var message = "";
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
// describe multiple calls
if (l > 1) {
message += "\nCall " + (i + 1) + ":";
}
var calledArgs = spyInstance.getCall(i).args;
for (var j = 0; j < calledArgs.length || j < args.length; ++j) {
message += "\n";
var calledArgMessage = j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
if (match.isMatcher(args[j])) {
message += colorSinonMatchText(args[j], calledArgs[j], calledArgMessage);
} else {
var expectedArgMessage = j < args.length ? sinonFormat(args[j]) : "";
var diff = jsDiff.diffJson(calledArgMessage, expectedArgMessage);
message += colorDiffText(diff);
}
}
}
return message;
},
C: function(spyInstance) {
var calls = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
// eslint-disable-next-line local-rules/no-prototype-methods
var stringifiedCall = " " + spyInstance.getCall(i).toString();
if (/\n/.test(calls[i - 1])) {
stringifiedCall = "\n" + stringifiedCall;
}
push(calls, stringifiedCall);
}
return calls.length > 0 ? "\n" + join(calls, "\n") : "";
},
t: function(spyInstance) {
var objects = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
push(objects, sinonFormat(spyInstance.thisValues[i]));
}
return join(objects, ", ");
},
"*": function(spyInstance, args) {
return join(
map(args, function(arg) {
return sinonFormat(arg);
}),
", "
);
}
};
},{"./color":6,"./util/core/format":22,"./util/core/times-in-words":30,"@sinonjs/commons":39,"@sinonjs/samsam":65,"diff":69}],14:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var createBehavior = require("./behavior").create;
var extend = require("./util/core/extend");
var functionName = require("@sinonjs/commons").functionName;
var functionToString = require("./util/core/function-to-string");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var deepEqual = require("@sinonjs/samsam").deepEqual;
var isEsModule = require("./util/core/is-es-module");
var spyCall = require("./call");
var wrapMethod = require("./util/core/wrap-method");
var sinonFormat = require("./util/core/format");
var valueToString = require("@sinonjs/commons").valueToString;
/* cache references to library methods so that they also can be stubbed without problems */
var concat = arrayProto.concat;
var forEach = arrayProto.forEach;
var pop = arrayProto.pop;
var push = arrayProto.push;
var slice = arrayProto.slice;
var filter = Array.prototype.filter;
var ErrorConstructor = Error.prototype.constructor;
var bind = Function.prototype.bind;
var callId = 0;
function spy(object, property, types) {
var descriptor, methodDesc;
if (isEsModule(object)) {
throw new TypeError("ES Modules cannot be spied");
}
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function() {
return;
});
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
forEach(types, function(type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}
function incrementCallCount() {
this.called = true;
this.callCount += 1;
this.notCalled = false;
this.calledOnce = this.callCount === 1;
this.calledTwice = this.callCount === 2;
this.calledThrice = this.callCount === 3;
}
function createCallProperties() {
this.firstCall = this.getCall(0);
this.secondCall = this.getCall(1);
this.thirdCall = this.getCall(2);
this.lastCall = this.getCall(this.callCount - 1);
}
function createProxy(func, proxyLength) {
// Retain the function length:
var p;
if (proxyLength) {
// 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 (proxyLength) {
/*eslint-disable no-unused-vars, max-len*/
case 1:
p = function proxy(a) {
return p.invoke(func, this, slice(arguments));
};
break;
case 2:
p = function proxy(a, b) {
return p.invoke(func, this, slice(arguments));
};
break;
case 3:
p = function proxy(a, b, c) {
return p.invoke(func, this, slice(arguments));
};
break;
case 4:
p = function proxy(a, b, c, d) {
return p.invoke(func, this, slice(arguments));
};
break;
case 5:
p = function proxy(a, b, c, d, e) {
return p.invoke(func, this, slice(arguments));
};
break;
case 6:
p = function proxy(a, b, c, d, e, f) {
return p.invoke(func, this, slice(arguments));
};
break;
case 7:
p = function proxy(a, b, c, d, e, f, g) {
return p.invoke(func, this, slice(arguments));
};
break;
case 8:
p = function proxy(a, b, c, d, e, f, g, h) {
return p.invoke(func, this, slice(arguments));
};
break;
case 9:
p = function proxy(a, b, c, d, e, f, g, h, i) {
return p.invoke(func, this, slice(arguments));
};
break;
case 10:
p = function proxy(a, b, c, d, e, f, g, h, i, j) {
return p.invoke(func, this, slice(arguments));
};
break;
case 11:
p = function proxy(a, b, c, d, e, f, g, h, i, j, k) {
return p.invoke(func, this, slice(arguments));
};
break;
case 12:
p = function proxy(a, b, c, d, e, f, g, h, i, j, k, l) {
return p.invoke(func, this, slice(arguments));
};
break;
default:
p = function proxy() {
return p.invoke(func, this, slice(arguments));
};
break;
/*eslint-enable*/
}
} else {
p = function proxy() {
return p.invoke(func, this, slice(arguments));
};
}
var nameDescriptor = Object.getOwnPropertyDescriptor(func, "name");
if (nameDescriptor && nameDescriptor.configurable) {
// IE 11 functions don't have a name.
// Safari 9 has names that are not configurable.
Object.defineProperty(p, "name", nameDescriptor);
}
extend.nonEnum(p, {
isSinonProxy: true,
called: false,
notCalled: true,
calledOnce: false,
calledTwice: false,
calledThrice: false,
callCount: 0,
firstCall: null,
secondCall: null,
thirdCall: null,
lastCall: null,
args: [],
returnValues: [],
thisValues: [],
exceptions: [],
callIds: [],
errorsWithCallStack: []
});
return p;
}
var uuid = 0;
// Public API
var spyApi = {
formatters: require("./spy-formatters"),
resetHistory: function() {
if (this.invoking) {
var err = new Error(
"Cannot reset Sinon function while invoking it. " +
"Move the call to .resetHistory outside of the callback."
);
err.name = "InvalidResetException";
throw err;
}
this.called = false;
this.notCalled = true;
this.calledOnce = false;
this.calledTwice = false;
this.calledThrice = false;
this.callCount = 0;
this.firstCall = null;
this.secondCall = null;
this.thirdCall = null;
this.lastCall = null;
this.args = [];
this.returnValues = [];
this.thisValues = [];
this.exceptions = [];
this.callIds = [];
this.errorsWithCallStack = [];
if (this.fakes) {
forEach(this.fakes, function(fake) {
if (fake.resetHistory) {
fake.resetHistory();
} else {
fake.reset();
}
});
}
return this;
},
create: function create(func, spyLength) {
var name;
var funk = func;
if (typeof funk !== "function") {
funk = function() {
return;
};
} else {
name = functionName(funk);
}
var length = spyLength || funk.length;
var proxy = createProxy(funk, length);
extend.nonEnum(proxy, spy);
delete proxy.create;
extend(proxy, funk);
proxy.resetHistory();
proxy.prototype = funk.prototype;
extend.nonEnum(proxy, {
displayName: name || "spy",
toString: functionToString,
instantiateFake: spy.create,
id: "spy#" + uuid++
});
return proxy;
},
invoke: function invoke(func, thisValue, args) {
var matchings = this.matchingFakes(args);
var currentCallId = callId++;
var exception, returnValue;
incrementCallCount.call(this);
push(this.thisValues, thisValue);
push(this.args, args);
push(this.callIds, currentCallId);
forEach(matchings, function(matching) {
incrementCallCount.call(matching);
push(matching.thisValues, thisValue);
push(matching.args, args);
push(matching.callIds, currentCallId);
});
// Make call properties available from within the spied function:
createCallProperties.call(this);
forEach(matchings, function(matching) {
createCallProperties.call(matching);
});
try {
this.invoking = true;
var thisCall = this.getCall(this.callCount - 1);
if (thisCall.calledWithNew()) {
// Call through with `new`
returnValue = new (bind.apply(this.func || func, concat([thisValue], args)))();
if (typeof returnValue !== "object") {
returnValue = thisValue;
}
} else {
returnValue = (this.func || func).apply(thisValue, args);
}
} catch (e) {
exception = e;
} finally {
delete this.invoking;
}
push(this.exceptions, exception);
push(this.returnValues, returnValue);
forEach(matchings, function(matching) {
push(matching.exceptions, exception);
push(matching.returnValues, returnValue);
});
var 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
try {
throw err;
} catch (e) {
/* empty */
}
push(this.errorsWithCallStack, err);
forEach(matchings, function(matching) {
push(matching.errorsWithCallStack, err);
});
// Make return value and exception available in the calls:
createCallProperties.call(this);
forEach(matchings, function(matching) {
createCallProperties.call(matching);
});
if (exception !== undefined) {
throw exception;
}
return returnValue;
},
named: function named(name) {
this.displayName = name;
var 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.
nameDescriptor.value = name;
Object.defineProperty(this, "name", nameDescriptor);
}
return this;
},
getCall: function getCall(i) {
if (i < 0 || i >= this.callCount) {
return null;
}
return spyCall(
this,
this.thisValues[i],
this.args[i],
this.returnValues[i],
this.exceptions[i],
this.callIds[i],
this.errorsWithCallStack[i]
);
},
getCalls: function() {
var calls = [];
var i;
for (i = 0; i < this.callCount; i++) {
push(calls, this.getCall(i));
}
return calls;
},
calledBefore: function calledBefore(spyFn) {
if (!this.called) {
return false;
}
if (!spyFn.called) {
return true;
}
return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1];
},
calledAfter: function calledAfter(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] > spyFn.callIds[0];
},
calledImmediatelyBefore: function calledImmediatelyBefore(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] === spyFn.callIds[spyFn.callCount - 1] - 1;
},
calledImmediatelyAfter: function calledImmediatelyAfter(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] === spyFn.callIds[spyFn.callCount - 1] + 1;
},
withArgs: function() {
var args = slice(arguments);
if (this.fakes) {
var matching = pop(this.matchingFakes(args, true));
if (matching) {
return matching;
}
} else {
extend.nonEnum(this, { fakes: [] });
}
var original = this;
var fake = this.instantiateFake();
fake.matchingArguments = args;
fake.parent = this;
push(this.fakes, fake);
if (original.defaultBehavior && original.defaultBehavior.promiseLibrary) {
fake.defaultBehavior = fake.defaultBehavior || createBehavior(fake);
fake.defaultBehavior.promiseLibrary = original.defaultBehavior.promiseLibrary;
}
fake.withArgs = function() {
return original.withArgs.apply(original, arguments);
};
forEach(original.args, function(arg, i) {
if (!fake.matches(arg)) {
return;
}
incrementCallCount.call(fake);
push(fake.thisValues, original.thisValues[i]);
push(fake.args, arg);
push(fake.returnValues, original.returnValues[i]);
push(fake.exceptions, original.exceptions[i]);
push(fake.callIds, original.callIds[i]);
});
createCallProperties.call(fake);
return fake;
},
matchingFakes: function(args, strict) {
return filter.call(this.fakes || [], function(fake) {
return fake.matches(args, strict);
});
},
matches: function(args, strict) {
var margs = this.matchingArguments;
if (margs.length <= args.length && deepEqual(slice(args, 0, margs.length), margs)) {
return !strict || margs.length === args.length;
}
return undefined;
},
printf: function(format) {
var spyInstance = this;
var args = slice(arguments, 1);
var formatter;
return (format || "").replace(/%(.)/g, function(match, specifyer) {
formatter = spyApi.formatters[specifyer];
if (typeof formatter === "function") {
return String(formatter(spyInstance, args));
} else if (!isNaN(parseInt(specifyer, 10))) {
return sinonFormat(args[specifyer - 1]);
}
return "%" + specifyer;
});
}
};
function delegateToCalls(method, matchAny, actual, returnsValues, notCalled, totalCallCount) {
spyApi[method] = function() {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
if (totalCallCount !== undefined && this.callCount !== totalCallCount) {
return false;
}
var currentCall;
var matches = 0;
var returnValues = [];
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
var returnValue = currentCall[actual || method].apply(currentCall, arguments);
push(returnValues, returnValue);
if (returnValue) {
matches += 1;
if (matchAny) {
return true;
}
}
}
if (returnsValues) {
return returnValues;
}
return matches === this.callCount;
};
}
delegateToCalls("calledOn", true);
delegateToCalls("alwaysCalledOn", false, "calledOn");
delegateToCalls("calledWith", true);
delegateToCalls("calledOnceWith", true, "calledWith", false, undefined, 1);
delegateToCalls("calledWithMatch", true);
delegateToCalls("alwaysCalledWith", false, "calledWith");
delegateToCalls("alwaysCalledWithMatch", false, "calledWithMatch");
delegateToCalls("calledWithExactly", true);
delegateToCalls("calledOnceWithExactly", true, "calledWithExactly", false, undefined, 1);
delegateToCalls("alwaysCalledWithExactly", false, "calledWithExactly");
delegateToCalls("neverCalledWith", false, "notCalledWith", false, function() {
return true;
});
delegateToCalls("neverCalledWithMatch", false, "notCalledWithMatch", false, function() {
return true;
});
delegateToCalls("threw", true);
delegateToCalls("alwaysThrew", false, "threw");
delegateToCalls("returned", true);
delegateToCalls("alwaysReturned", false, "returned");
delegateToCalls("calledWithNew", true);
delegateToCalls("alwaysCalledWithNew", false, "calledWithNew");
/* eslint-disable local-rules/no-prototype-methods */
delegateToCalls("callArg", false, "callArgWith", true, function() {
throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
});
spyApi.callArgWith = spyApi.callArg;
delegateToCalls("callArgOn", false, "callArgOnWith", true, function() {
throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
});
spyApi.callArgOnWith = spyApi.callArgOn;
delegateToCalls("throwArg", false, "throwArg", false, function() {
throw new Error(this.toString() + " cannot throw arg since it was not yet invoked.");
});
delegateToCalls("yield", false, "yield", true, function() {
throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
});
// "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode.
spyApi.invokeCallback = spyApi.yield;
delegateToCalls("yieldOn", false, "yieldOn", true, function() {
throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
});
delegateToCalls("yieldTo", false, "yieldTo", true, function(property) {
throw new Error(
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
);
});
delegateToCalls("yieldToOn", false, "yieldToOn", true, function(property) {
throw new Error(
this.toString() + " cannot yield to '" + valueToString(property) + "' since it was not yet invoked."
);
});
/* eslint-enable local-rules/no-prototype-methods */
extend(spy, spyApi);
spy.spyCall = spyCall;
module.exports = spy;
},{"./behavior":3,"./call":4,"./spy-formatters":13,"./util/core/extend":21,"./util/core/format":22,"./util/core/function-to-string":23,"./util/core/get-property-descriptor":25,"./util/core/is-es-module":26,"./util/core/wrap-method":33,"@sinonjs/commons":39,"@sinonjs/samsam":65}],15:[function(require,module,exports){
"use strict";
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var walk = require("./util/core/walk");
function stubEntireObject(stub, object) {
walk(object || {}, function(prop, propOwner) {
// we don't want to stub things like toString(), valueOf(), etc. so we only stub if the object
// is not Object.prototype
if (
propOwner !== Object.prototype &&
prop !== "constructor" &&
typeof getPropertyDescriptor(propOwner, prop).value === "function"
) {
stub(object, prop);
}
});
return object;
}
module.exports = stubEntireObject;
},{"./util/core/get-property-descriptor":25,"./util/core/walk":32}],16:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var behavior = require("./behavior");
var behaviors = require("./default-behaviors");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var isNonExistentOwnProperty = require("./util/core/is-non-existent-own-property");
var spy = require("./spy");
var extend = require("./util/core/extend");
var functionToString = require("./util/core/function-to-string");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var isEsModule = require("./util/core/is-es-module");
var wrapMethod = require("./util/core/wrap-method");
var stubEntireObject = require("./stub-entire-object");
var throwOnFalsyObject = require("./throw-on-falsy-object");
var valueToString = require("@sinonjs/commons").valueToString;
var forEach = arrayProto.forEach;
var pop = arrayProto.pop;
var slice = arrayProto.slice;
var sort = arrayProto.sort;
function stub(object, property) {
if (arguments.length > 2) {
throw new TypeError("stub(obj, 'meth', fn) has been removed, see documentation");
}
if (isEsModule(object)) {
throw new TypeError("ES Modules cannot be stubbed");
}
throwOnFalsyObject.apply(null, arguments);
if (isNonExistentOwnProperty(object, property)) {
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
}
var actualDescriptor = getPropertyDescriptor(object, property);
var isObject = typeof object === "object" || typeof object === "function";
var isStubbingEntireObject = typeof property === "undefined" && isObject;
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingNonFuncProperty =
isObject &&
typeof property !== "undefined" &&
(typeof actualDescriptor === "undefined" || typeof actualDescriptor.value !== "function") &&
typeof descriptor === "undefined";
var isStubbingExistingMethod =
typeof object === "object" &&
typeof actualDescriptor !== "undefined" &&
typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
extend.nonEnum(s, {
rootObj: object,
propName: property,
restore: function restore() {
if (actualDescriptor !== undefined) {
Object.defineProperty(object, property, actualDescriptor);
return;
}
delete 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;
};
/*eslint-disable no-use-before-define*/
function getParentBehaviour(stubInstance) {
return stubInstance.parent && getCurrentBehavior(stubInstance.parent);
}
function getDefaultBehavior(stubInstance) {
return stubInstance.defaultBehavior || getParentBehaviour(stubInstance) || behavior.create(stubInstance);
}
function getCurrentBehavior(stubInstance) {
var currentBehavior = stubInstance.behaviors[stubInstance.callCount - 1];
return currentBehavior && currentBehavior.isPresent() ? currentBehavior : getDefaultBehavior(stubInstance);
}
/*eslint-enable no-use-before-define*/
var uuid = 0;
var proto = {
create: function create(stubLength) {
var functionStub = function() {
var args = slice(arguments);
var matchings = functionStub.matchingFakes(args);
var fnStub =
pop(
sort(matchings, function(a, b) {
return a.matchingArguments.length - b.matchingArguments.length;
})
) || functionStub;
return getCurrentBehavior(fnStub).invoke(this, arguments);
};
var orig = functionStub;
functionStub = spy.create(functionStub, stubLength);
extend.nonEnum(functionStub, {
id: "stub#" + uuid++,
func: orig
});
extend(functionStub, stub);
extend.nonEnum(functionStub, {
instantiateFake: stub.create,
displayName: "stub",
toString: functionToString,
defaultBehavior: null,
behaviors: []
});
return functionStub;
},
resetBehavior: function() {
var fakes = this.fakes || [];
this.defaultBehavior = null;
this.behaviors = [];
delete this.returnValue;
delete this.returnArgAt;
delete this.throwArgAt;
delete this.resolveArgAt;
delete this.fakeFn;
this.returnThis = false;
this.resolveThis = false;
forEach(fakes, function(fake) {
fake.resetBehavior();
});
},
resetHistory: spy.resetHistory,
reset: function() {
this.resetHistory();
this.resetBehavior();
},
onCall: function onCall(index) {
if (!this.behaviors[index]) {
this.behaviors[index] = behavior.create(this);
}
return this.behaviors[index];
},
onFirstCall: function onFirstCall() {
return this.onCall(0);
},
onSecondCall: function onSecondCall() {
return this.onCall(1);
},
onThirdCall: function onThirdCall() {
return this.onCall(2);
}
};
forEach(Object.keys(behavior), function(method) {
if (
hasOwnProperty(behavior, method) &&
!hasOwnProperty(proto, method) &&
method !== "create" &&
method !== "withArgs" &&
method !== "invoke"
) {
proto[method] = behavior.createBehavior(method);
}
});
forEach(Object.keys(behaviors), function(method) {
if (hasOwnProperty(behaviors, method) && !hasOwnProperty(proto, method)) {
behavior.addBehavior(stub, method, behaviors[method]);
}
});
extend(stub, proto);
module.exports = stub;
},{"./behavior":3,"./default-behaviors":8,"./spy":14,"./stub-entire-object":15,"./throw-on-falsy-object":17,"./util/core/extend":21,"./util/core/function-to-string":23,"./util/core/get-property-descriptor":25,"./util/core/is-es-module":26,"./util/core/is-non-existent-own-property":27,"./util/core/wrap-method":33,"@sinonjs/commons":39}],17:[function(require,module,exports){
"use strict";
var valueToString = require("@sinonjs/commons").valueToString;
function throwOnFalsyObject(object, property) {
if (property && !object) {
var type = object === null ? "null" : "undefined";
throw new Error("Trying to stub property '" + valueToString(property) + "' of " + type);
}
}
module.exports = throwOnFalsyObject;
},{"@sinonjs/commons":39}],18:[function(require,module,exports){
"use strict";
module.exports = {
injectIntoThis: true,
injectInto: null,
properties: ["spy", "stub", "mock", "clock", "server", "requests"],
useFakeTimers: true,
useFakeServer: true
};
},{}],19:[function(require,module,exports){
/* eslint-disable no-console */
"use strict";
// wrap returns a function that will invoke the supplied function and print a deprecation warning to the console each
// time it is called.
exports.wrap = function(func, msg) {
var wrapped = function() {
exports.printWarning(msg);
return func.apply(this, arguments);
};
if (func.prototype) {
wrapped.prototype = func.prototype;
}
return wrapped;
};
// defaultMsg returns a string which can be supplied to `wrap()` to notify the user that a particular part of the
// sinon API has been deprecated.
/* istanbul ignore next */
exports.defaultMsg = function(funcName) {
return "sinon." + funcName + " is deprecated and will be removed from the public API in a future version of sinon.";
};
exports.printWarning = function(msg) {
// Watch out for IE7 and below! :(
if (typeof console !== "undefined") {
/* istanbul ignore else */
if (console.info) {
console.info(msg);
} else {
console.log(msg);
}
}
};
},{}],20:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var reduce = arrayProto.reduce;
module.exports = function exportAsyncBehaviors(behaviorMethods) {
return reduce(
Object.keys(behaviorMethods),
function(acc, method) {
// 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);
this.callbackAsync = true;
return result;
};
}
return acc;
},
{}
);
};
},{"@sinonjs/commons":39}],21:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var join = arrayProto.join;
var push = arrayProto.push;
var slice = arrayProto.slice;
// Adapted from https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
var hasDontEnumBug = (function() {
var 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";
}
};
var result = [];
for (var prop in obj) {
if (hasOwnProperty(obj, prop)) {
push(result, obj[prop]());
}
}
return join(result, "") !== "0123456789";
})();
function extendCommon(target, sources, doCopy) {
var 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);
}
}
// Make sure we copy (own) toString method even when in JScript with DontEnum bug
// See https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
if (hasDontEnumBug && hasOwnProperty(source, "toString") && source.toString !== target.toString) {
target.toString = source.toString;
}
}
return target;
}
/** Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
* override properties in previous sources.
*
* @arg {Object} target - The Object to extend
* @arg {Object[]} sources - Objects to copy properties from.
*
* @returns {Object} the extended target
*/
module.exports = function extend(target /*, sources */) {
var sources = slice(arguments, 1);
return extendCommon(target, sources, function copyValue(dest, source, prop) {
dest[prop] = source[prop];
});
};
/** 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.
*
* @arg {Object} target - The Object to extend
* @arg {Object[]} sources - Objects to copy properties from.
*
* @returns {Object} the extended target
*/
module.exports.nonEnum = function extendNonEnum(target /*, sources */) {
var sources = slice(arguments, 1);
return extendCommon(target, sources, function copyProperty(dest, source, prop) {
Object.defineProperty(dest, prop, {
value: source[prop],
enumerable: false,
configurable: true,
writable: true
});
});
};
},{"@sinonjs/commons":39}],22:[function(require,module,exports){
"use strict";
var formatio = require("@sinonjs/formatio");
var formatter = formatio.configure({
quoteStrings: false,
limitChildrenCount: 250
});
var customFormatter;
function format() {
if (customFormatter) {
return customFormatter.apply(null, arguments);
}
return formatter.ascii.apply(formatter, arguments);
}
format.setFormatter = function(aCustomFormatter) {
if (typeof aCustomFormatter !== "function") {
throw new Error("format.setFormatter must be called with a function");
}
customFormatter = aCustomFormatter;
};
module.exports = format;
},{"@sinonjs/formatio":49}],23:[function(require,module,exports){
"use strict";
module.exports = function toString() {
var i, prop, thisValue;
if (this.getCall && this.callCount) {
i = this.callCount;
while (i--) {
thisValue = this.getCall(i).thisValue;
for (prop in thisValue) {
if (thisValue[prop] === this) {
return prop;
}
}
}
}
return this.displayName || "sinon fake";
};
},{}],24:[function(require,module,exports){
"use strict";
/* istanbul ignore next : not testing that setTimeout works */
function nextTick(callback) {
setTimeout(callback, 0);
}
module.exports = function getNextTick(process, setImmediate) {
if (typeof process === "object" && typeof process.nextTick === "function") {
return process.nextTick;
}
if (typeof setImmediate === "function") {
return setImmediate;
}
return nextTick;
};
},{}],25:[function(require,module,exports){
"use strict";
module.exports = function getPropertyDescriptor(object, property) {
var proto = object;
var descriptor;
while (proto && !(descriptor = Object.getOwnPropertyDescriptor(proto, property))) {
proto = Object.getPrototypeOf(proto);
}
return descriptor;
};
},{}],26:[function(require,module,exports){
"use strict";
/**
* Verify if an object is a ECMAScript Module
*
* As the exports from a module is immutable we cannot alter the exports
* using spies or stubs. Let the consumer know this to avoid bug reports
* on weird error messages.
*
* @param {Object} object The object to examine
*
* @returns {Boolean} true when the object is a module
*/
module.exports = function(object) {
return (
object && typeof Symbol !== "undefined" && object[Symbol.toStringTag] === "Module" && Object.isSealed(object)
);
};
},{}],27:[function(require,module,exports){
"use strict";
function isNonExistentOwnProperty(object, property) {
return object && typeof property !== "undefined" && !(property in object);
}
module.exports = isNonExistentOwnProperty;
},{}],28:[function(require,module,exports){
"use strict";
var getPropertyDescriptor = require("./get-property-descriptor");
function isPropertyConfigurable(obj, propName) {
var propertyDescriptor = getPropertyDescriptor(obj, propName);
return propertyDescriptor ? propertyDescriptor.configurable : true;
}
module.exports = isPropertyConfigurable;
},{"./get-property-descriptor":25}],29:[function(require,module,exports){
(function (global){
"use strict";
var getNextTick = require("./get-next-tick");
/* istanbul ignore next */
var root = typeof window !== "undefined" ? window : global;
module.exports = getNextTick(root.process, root.setImmediate);
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./get-next-tick":24}],30:[function(require,module,exports){
"use strict";
var array = [null, "once", "twice", "thrice"];
module.exports = function timesInWords(count) {
return array[count] || (count || 0) + " times";
};
},{}],31:[function(require,module,exports){
"use strict";
var forEach = Array.prototype.forEach;
function usePromiseLibrary(library, fakes) {
if (typeof library === "undefined") {
return;
}
if (Array.isArray(fakes)) {
forEach.call(fakes, usePromiseLibrary.bind(null, library));
return;
}
if (typeof fakes.usingPromise === "function") {
fakes.usingPromise(library);
}
}
module.exports = usePromiseLibrary;
},{}],32:[function(require,module,exports){
"use strict";
var forEach = require("@sinonjs/commons").prototypes.array.forEach;
function walkInternal(obj, iterator, context, originalObj, seen) {
var proto, prop;
if (typeof Object.getOwnPropertyNames !== "function") {
// We explicitly want to enumerate through all of the prototype's properties
// in this case, therefore we deliberately leave out an own property check.
/* eslint-disable-next-line guard-for-in */
for (prop in obj) {
iterator.call(context, obj[prop], prop, obj);
}
return;
}
forEach(Object.getOwnPropertyNames(obj), function(k) {
if (seen[k] !== true) {
seen[k] = true;
var target = typeof Object.getOwnPropertyDescriptor(obj, k).get === "function" ? originalObj : obj;
iterator.call(context, k, target);
}
});
proto = Object.getPrototypeOf(obj);
if (proto) {
walkInternal(proto, iterator, context, originalObj, seen);
}
}
/* Walks the prototype chain of an object and iterates over every own property
* name encountered. The iterator is called in the same fashion that Array.prototype.forEach
* works, where it is passed the value, key, and own object as the 1st, 2nd, and 3rd positional
* argument, respectively. In cases where Object.getOwnPropertyNames is not available, walk will
* default to using a simple for..in loop.
*
* obj - The object to walk the prototype chain for.
* iterator - The function to be called on each pass of the walk.
* context - (Optional) When given, the iterator will be called with this object as the receiver.
*/
module.exports = function walk(obj, iterator, context) {
return walkInternal(obj, iterator, context, obj, {});
};
},{"@sinonjs/commons":39}],33:[function(require,module,exports){
"use strict";
var getPropertyDescriptor = require("./get-property-descriptor");
var extend = require("./extend");
var hasOwnProperty = require("@sinonjs/commons").prototypes.object.hasOwnProperty;
var valueToString = require("@sinonjs/commons").valueToString;
function isFunction(obj) {
return typeof obj === "function" || Boolean(obj && obj.constructor && obj.call && obj.apply);
}
function mirrorProperties(target, source) {
for (var prop in source) {
if (!hasOwnProperty(target, prop)) {
target[prop] = source[prop];
}
}
}
// Cheap way to detect if we have ES5 support.
var hasES5Support = "keys" in Object;
module.exports = function wrapMethod(object, property, method) {
if (!object) {
throw new TypeError("Should wrap property of object");
}
if (typeof method !== "function" && typeof method !== "object") {
throw new TypeError("Method wrapper should be a function or a property descriptor");
}
function checkWrappedMethod(wrappedMethod) {
var error;
if (!isFunction(wrappedMethod)) {
error = new TypeError(
"Attempted to wrap " + typeof wrappedMethod + " property " + valueToString(property) + " as function"
);
} else if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already wrapped");
} else if (wrappedMethod.calledBefore) {
var verb = wrappedMethod.returns ? "stubbed" : "spied on";
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already " + verb);
}
if (error) {
if (wrappedMethod && wrappedMethod.stackTraceError) {
error.stack += "\n--------------\n" + wrappedMethod.stackTraceError.stack;
}
throw error;
}
}
var error, wrappedMethod, i, wrappedMethodDesc;
function simplePropertyAssignment() {
wrappedMethod = object[property];
checkWrappedMethod(wrappedMethod);
object[property] = method;
method.displayName = property;
}
// Firefox has a problem when using hasOwn.call on objects from other frames.
/* eslint-disable-next-line local-rules/no-prototype-methods */
var owned = object.hasOwnProperty ? object.hasOwnProperty(property) : hasOwnProperty(object, property);
if (hasES5Support) {
var methodDesc = typeof method === "function" ? { value: method } : method;
wrappedMethodDesc = getPropertyDescriptor(object, property);
if (!wrappedMethodDesc) {
error = new TypeError(
"Attempted to wrap " + typeof wrappedMethod + " property " + property + " as function"
);
} else if (wrappedMethodDesc.restore && wrappedMethodDesc.restore.sinon) {
error = new TypeError("Attempted to wrap " + property + " which is already wrapped");
}
if (error) {
if (wrappedMethodDesc && wrappedMethodDesc.stackTraceError) {
error.stack += "\n--------------\n" + wrappedMethodDesc.stackTraceError.stack;
}
throw error;
}
var types = Object.keys(methodDesc);
for (i = 0; i < types.length; i++) {
wrappedMethod = wrappedMethodDesc[types[i]];
checkWrappedMethod(wrappedMethod);
}
mirrorProperties(methodDesc, wrappedMethodDesc);
for (i = 0; i < types.length; i++) {
mirrorProperties(methodDesc[types[i]], wrappedMethodDesc[types[i]]);
}
Object.defineProperty(object, property, methodDesc);
// catch failing assignment
// this is the converse of the check in `.restore` below
if (typeof method === "function" && object[property] !== method) {
// correct any wrongdoings caused by the defineProperty call above,
// such as adding new items (if object was a Storage object)
delete object[property];
simplePropertyAssignment();
}
} else {
simplePropertyAssignment();
}
extend.nonEnum(method, {
displayName: property,
// Set up an Error object for a stack trace which can be used later to find what line of
// code the original method was created on.
stackTraceError: new Error("Stack Trace for original"),
restore: function() {
// For prototype properties try to reset by delete first.
// If this fails (ex: localStorage on mobile safari) then force a reset
// via direct assignment.
if (!owned) {
// In some cases `delete` may throw an error
try {
delete object[property];
} catch (e) {} // eslint-disable-line no-empty
// For native code functions `delete` fails without throwing an error
// on Chrome < 43, PhantomJS, etc.
} else if (hasES5Support) {
Object.defineProperty(object, property, wrappedMethodDesc);
}
if (hasES5Support) {
var descriptor = getPropertyDescriptor(object, property);
if (descriptor && descriptor.value === method) {
object[property] = wrappedMethod;
}
} else {
// Use strict equality comparison to check failures then force a reset
// via direct assignment.
if (object[property] === method) {
object[property] = wrappedMethod;
}
}
}
});
method.wrappedMethod = wrappedMethod;
method.restore.sinon = true;
if (!hasES5Support) {
mirrorProperties(method, wrappedMethod);
}
return method;
};
},{"./extend":21,"./get-property-descriptor":25,"@sinonjs/commons":39}],34:[function(require,module,exports){
"use strict";
var extend = require("./core/extend");
var llx = require("lolex");
function createClock(config, globalCtx) {
var llxCtx = llx;
if (globalCtx !== null && typeof globalCtx === "object") {
llxCtx = llx.withGlobal(globalCtx);
}
var clock = llxCtx.install(config);
clock.restore = clock.uninstall;
return clock;
}
/**
* @param {number|Date|Object} dateOrConfig The unix epoch value to install with (default 0)
* @returns {Object} Returns a lolex clock instance
*/
exports.useFakeTimers = function(dateOrConfig) {
var hasArguments = typeof dateOrConfig !== "undefined";
var argumentIsDateLike =
(typeof dateOrConfig === "number" || dateOrConfig instanceof Date) && arguments.length === 1;
var argumentIsObject = dateOrConfig !== null && typeof dateOrConfig === "object" && arguments.length === 1;
if (!hasArguments) {
return createClock({
now: 0
});
}
if (argumentIsDateLike) {
return createClock({
now: dateOrConfig
});
}
if (argumentIsObject) {
var config = extend.nonEnum({}, dateOrConfig);
var globalCtx = config.global;
delete config.global;
return createClock(config, globalCtx);
}
throw new TypeError("useFakeTimers expected epoch or config object. See https://github.com/sinonjs/sinon");
};
exports.clock = {
create: function(now) {
return llx.createClock(now);
}
};
exports.timers = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setImmediate: typeof setImmediate !== "undefined" ? setImmediate : undefined,
clearImmediate: typeof clearImmediate !== "undefined" ? clearImmediate : undefined,
setInterval: setInterval,
clearInterval: clearInterval,
Date: Date
};
},{"./core/extend":21,"lolex":73}],35:[function(require,module,exports){
"use strict";
var every = require("./prototypes/array").every;
function hasCallsLeft(callMap, spy) {
if (callMap[spy.id] === undefined) {
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;
}
module.exports = function calledInOrder(spies) {
var callMap = {};
// eslint-disable-next-line no-underscore-dangle
var _spies = arguments.length > 1 ? arguments : spies;
return every(_spies, checkAdjacentCalls.bind(null, callMap));
};
},{"./prototypes/array":41}],36:[function(require,module,exports){
"use strict";
var functionName = require("./function-name");
module.exports = function className(value) {
return (
(value.constructor && value.constructor.name) ||
// The next branch is for IE11 support only:
// Because the name property is not set on the prototype
// of the Function object, we finally try to grab the
// name from its definition. This will never be reached
// in node, so we are not able to test this properly.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
(typeof value.constructor === "function" &&
/* istanbul ignore next */
functionName(value.constructor)) ||
null
);
};
},{"./function-name":38}],37:[function(require,module,exports){
"use strict";
// This is an `every` implementation that works for all iterables
module.exports = function every(obj, fn) {
var pass = true;
try {
/* eslint-disable-next-line local-rules/no-prototype-methods */
obj.forEach(function() {
if (!fn.apply(this, arguments)) {
// Throwing an error is the only way to break `forEach`
throw new Error();
}
});
} catch (e) {
pass = false;
}
return pass;
};
},{}],38:[function(require,module,exports){
"use strict";
module.exports = function functionName(func) {
if (!func) {
return "";
}
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]
);
};
},{}],39:[function(require,module,exports){
"use strict";
module.exports = {
calledInOrder: require("./called-in-order"),
className: require("./class-name"),
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")
};
},{"./called-in-order":35,"./class-name":36,"./every":37,"./function-name":38,"./order-by-first-call":40,"./prototypes":44,"./type-of":47,"./value-to-string":48}],40:[function(require,module,exports){
"use strict";
var sort = require("./prototypes/array").sort;
var slice = require("./prototypes/array").slice;
function comparator(a, b) {
// uuid, won't ever be equal
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;
}
module.exports = function orderByFirstCall(spies) {
return sort(slice(spies), comparator);
};
},{"./prototypes/array":41}],41:[function(require,module,exports){
"use strict";
var copyPrototype = require("./copy-prototype");
module.exports = copyPrototype(Array.prototype);
},{"./copy-prototype":42}],42:[function(require,module,exports){
"use strict";
var call = Function.call;
module.exports = function copyPrototypeMethods(prototype) {
/* eslint-disable local-rules/no-prototype-methods */
return Object.getOwnPropertyNames(prototype).reduce(function(result, name) {
// ignore size because it throws from Map
if (
name !== "size" &&
name !== "caller" &&
name !== "callee" &&
name !== "arguments" &&
typeof prototype[name] === "function"
) {
result[name] = call.bind(prototype[name]);
}
return result;
}, Object.create(null));
};
},{}],43:[function(require,module,exports){
"use strict";
var copyPrototype = require("./copy-prototype");
module.exports = copyPrototype(Function.prototype);
},{"./copy-prototype":42}],44:[function(require,module,exports){
"use strict";
module.exports = {
array: require("./array"),
function: require("./function"),
object: require("./object"),
string: require("./string")
};
},{"./array":41,"./function":43,"./object":45,"./string":46}],45:[function(require,module,exports){
"use strict";
var copyPrototype = require("./copy-prototype");
module.exports = copyPrototype(Object.prototype);
},{"./copy-prototype":42}],46:[function(require,module,exports){
"use strict";
var copyPrototype = require("./copy-prototype");
module.exports = copyPrototype(String.prototype);
},{"./copy-prototype":42}],47:[function(require,module,exports){
"use strict";
var type = require("type-detect");
module.exports = function typeOf(value) {
return type(value).toLowerCase();
};
},{"type-detect":89}],48:[function(require,module,exports){
"use strict";
function valueToString(value) {
if (value && value.toString) {
/* eslint-disable-next-line local-rules/no-prototype-methods */
return value.toString();
}
return String(value);
}
module.exports = valueToString;
},{}],49:[function(require,module,exports){
(function (global){
"use strict";
var samsam = require("@sinonjs/samsam");
var functionName = require("@sinonjs/commons").functionName;
var typeOf = require("@sinonjs/commons").typeOf;
var formatio = {
excludeConstructors: ["Object", /^.$/],
quoteStrings: true,
limitChildrenCount: 0
};
var specialObjects = [];
if (typeof global !== "undefined") {
specialObjects.push({ object: global, value: "[object global]" });
}
if (typeof document !== "undefined") {
specialObjects.push({
object: document,
value: "[object HTMLDocument]"
});
}
if (typeof window !== "undefined") {
specialObjects.push({ object: window, value: "[object Window]" });
}
function constructorName(f, object) {
var name = functionName(object && object.constructor);
var excludes = f.excludeConstructors ||
formatio.excludeConstructors || [];
var i, l;
for (i = 0, l = excludes.length; i < l; ++i) {
if (typeof excludes[i] === "string" && excludes[i] === name) {
return "";
} else if (excludes[i].test && excludes[i].test(name)) {
return "";
}
}
return name;
}
function isCircular(object, objects) {
if (typeof object !== "object") { return false; }
var i, l;
for (i = 0, l = objects.length; i < l; ++i) {
if (objects[i] === object) { return true; }
}
return false;
}
function ascii(f, object, processed, indent) {
if (typeof object === "string") {
if (object.length === 0) { return "(empty string)"; }
var qs = f.quoteStrings;
var quote = typeof qs !== "boolean" || qs;
return processed || quote ? "\"" + object + "\"" : object;
}
if (typeof object === "symbol") {
return object.toString();
}
if (typeof object === "function" && !(object instanceof RegExp)) {
return ascii.func(object);
}
processed = processed || [];
if (isCircular(object, processed)) { return "[Circular]"; }
if (typeOf(object) === "array") {
return ascii.array.call(f, object, processed);
}
if (!object) { return String((1 / object) === -Infinity ? "-0" : object); }
if (samsam.isElement(object)) { return ascii.element(object); }
if (typeof object.toString === "function" &&
object.toString !== Object.prototype.toString) {
return object.toString();
}
var i, l;
for (i = 0, l = specialObjects.length; i < l; i++) {
if (object === specialObjects[i].object) {
return specialObjects[i].value;
}
}
if (samsam.isSet(object)) {
return ascii.set.call(f, object, processed);
}
return ascii.object.call(f, object, processed, indent);
}
ascii.func = function (func) {
var funcName = functionName(func) || "";
return "function " + funcName + "() {}";
};
function delimit(str, delimiters) {
delimiters = delimiters || ["[", "]"];
return delimiters[0] + str + delimiters[1];
}
ascii.array = function (array, processed, delimiters) {
processed = processed || [];
processed.push(array);
var pieces = [];
var i, l;
l = (this.limitChildrenCount > 0) ?
Math.min(this.limitChildrenCount, array.length) : array.length;
for (i = 0; i < l; ++i) {
pieces.push(ascii(this, array[i], processed));
}
if (l < array.length) {
pieces.push("[... " + (array.length - l) + " more elements]");
}
return delimit(pieces.join(", "), delimiters);
};
ascii.set = function (set, processed) {
return ascii.array.call(this, Array.from(set), processed, ["Set {", "}"]);
};
ascii.object = function (object, processed, indent) {
processed = processed || [];
processed.push(object);
indent = indent || 0;
var pieces = [];
var symbols = typeof Object.getOwnPropertySymbols === "function"
? Object.getOwnPropertySymbols(object)
: [];
var properties = Object.keys(object).sort().concat(symbols);
var length = 3;
var prop, str, obj, i, k, l;
l = (this.limitChildrenCount > 0) ?
Math.min(this.limitChildrenCount, properties.length) : properties.length;
for (i = 0; i < l; ++i) {
prop = properties[i];
obj = object[prop];
if (isCircular(obj, processed)) {
str = "[Circular]";
} else {
str = ascii(this, obj, processed, indent + 2);
}
str = (
typeof prop === "string" && /\s/.test(prop) ?
"\"" + prop + "\"" : prop.toString()
) + ": " + str;
length += str.length;
pieces.push(str);
}
var cons = constructorName(this, object);
var prefix = cons ? "[" + cons + "] " : "";
var is = "";
for (i = 0, k = indent; i < k; ++i) { is += " "; }
if (l < properties.length)
{pieces.push("[... " + (properties.length - l) + " more elements]");}
if (length + indent > 80) {
return prefix + "{\n " + is + pieces.join(",\n " + is) + "\n" +
is + "}";
}
return prefix + "{ " + pieces.join(", ") + " }";
};
ascii.element = function (element) {
var tagName = element.tagName.toLowerCase();
var attrs = element.attributes;
var pairs = [];
var attr, attrName, i, l, val;
for (i = 0, l = attrs.length; i < l; ++i) {
attr = attrs.item(i);
attrName = attr.nodeName.toLowerCase().replace("html:", "");
val = attr.nodeValue;
if (attrName !== "contenteditable" || val !== "inherit") {
if (val) { pairs.push(attrName + "=\"" + val + "\""); }
}
}
var formatted = "<" + tagName + (pairs.length > 0 ? " " : "");
// SVG elements have undefined innerHTML
var content = element.innerHTML || "";
if (content.length > 20) {
content = content.substr(0, 20) + "[...]";
}
var res = formatted + pairs.join(" ") + ">" + content +
"</" + tagName + ">";
return res.replace(/ contentEditable="inherit"/, "");
};
function Formatio(options) {
// eslint-disable-next-line guard-for-in
for (var opt in options) {
this[opt] = options[opt];
}
}
Formatio.prototype = {
functionName: functionName,
configure: function (options) {
return new Formatio(options);
},
constructorName: function (object) {
return constructorName(this, object);
},
ascii: function (object, processed, indent) {
return ascii(this, object, processed, indent);
}
};
module.exports = Formatio.prototype;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"@sinonjs/commons":39,"@sinonjs/samsam":65}],50:[function(require,module,exports){
"use strict";
var valueToString = require("@sinonjs/commons").valueToString;
var getClass = require("./get-class");
var identical = require("./identical");
var isArguments = require("./is-arguments");
var isDate = require("./is-date");
var isElement = require("./is-element");
var isNaN = require("./is-nan");
var isObject = require("./is-object");
var isSet = require("./is-set");
var isSubset = require("./is-subset");
var getClassName = require("./get-class-name");
var every = Array.prototype.every;
var getTime = Date.prototype.getTime;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var indexOf = Array.prototype.indexOf;
var keys = Object.keys;
/**
* @name samsam.deepEqual
* @param Object first
* @param Object second
*
* Deep equal comparison. Two values are "deep equal" if:
*
* - They are equal, according to samsam.identical
* - They are both date objects representing the same time
* - They are both arrays containing elements that are all deepEqual
* - They are objects with the same set of properties, and each property
* in ``first`` is deepEqual to the corresponding property in ``second``
*
* Supports cyclic objects.
*/
function deepEqualCyclic(first, second, match) {
// used for cyclic comparison
// contain already visited objects
var objects1 = [];
var objects2 = [];
// contain pathes (position in the object structure)
// of the already visited objects
// indexes same as in objects arrays
var paths1 = [];
var paths2 = [];
// contains combinations of already compared objects
// in the manner: { "$1['ref']$2['ref']": true }
var compared = {};
// does the recursion for the deep equal check
return (function deepEqual(obj1, obj2, path1, path2) {
// If both are matchers they must be the same instance in order to be
// considered equal If we didn't do that we would end up running one
// matcher against the other
if (match && match.isMatcher(obj2)) {
if (match.isMatcher(obj1)) {
return obj1 === obj2;
}
return obj2.test(obj1);
}
var type1 = typeof obj1;
var type2 = typeof obj2;
// == null also matches undefined
if (
obj1 === obj2 ||
isNaN(obj1) ||
isNaN(obj2) ||
obj1 == null ||
obj2 == null ||
type1 !== "object" ||
type2 !== "object"
) {
return identical(obj1, obj2);
}
// Elements are only equal if identical(expected, actual)
if (isElement(obj1) || isElement(obj2)) {
return false;
}
var isDate1 = isDate(obj1);
var isDate2 = isDate(obj2);
if (isDate1 || isDate2) {
if (
!isDate1 ||
!isDate2 ||
getTime.call(obj1) !== getTime.call(obj2)
) {
return false;
}
}
if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
if (valueToString(obj1) !== valueToString(obj2)) {
return false;
}
}
if (obj1 instanceof Error && obj2 instanceof Error) {
return obj1 === obj2;
}
var class1 = getClass(obj1);
var class2 = getClass(obj2);
var keys1 = keys(obj1);
var keys2 = keys(obj2);
var name1 = getClassName(obj1);
var name2 = getClassName(obj2);
if (isArguments(obj1) || isArguments(obj2)) {
if (obj1.length !== obj2.length) {
return false;
}
} else {
if (
type1 !== type2 ||
class1 !== class2 ||
keys1.length !== keys2.length ||
(name1 && name2 && name1 !== name2)
) {
return false;
}
}
if (isSet(obj1) || isSet(obj2)) {
if (!isSet(obj1) || !isSet(obj2) || obj1.size !== obj2.size) {
return false;
}
return isSubset(obj1, obj2, deepEqual);
}
return every.call(keys1, function(key) {
if (!hasOwnProperty.call(obj2, key)) {
return false;
}
var value1 = obj1[key];
var value2 = obj2[key];
var isObject1 = isObject(value1);
var isObject2 = isObject(value2);
// determines, if the objects were already visited
// (it's faster to check for isObject first, than to
// get -1 from getIndex for non objects)
var index1 = isObject1 ? indexOf.call(objects1, value1) : -1;
var index2 = isObject2 ? indexOf.call(objects2, value2) : -1;
// determines the new paths of the objects
// - for non cyclic objects the current path will be extended
// by current property name
// - for cyclic objects the stored path is taken
var newPath1 =
index1 !== -1
? paths1[index1]
: path1 + "[" + JSON.stringify(key) + "]";
var newPath2 =
index2 !== -1
? paths2[index2]
: path2 + "[" + JSON.stringify(key) + "]";
var combinedPath = newPath1 + newPath2;
// stop recursion if current objects are already compared
if (compared[combinedPath]) {
return true;
}
// remember the current objects and their paths
if (index1 === -1 && isObject1) {
objects1.push(value1);
paths1.push(newPath1);
}
if (index2 === -1 && isObject2) {
objects2.push(value2);
paths2.push(newPath2);
}
// remember that the current objects are already compared
if (isObject1 && isObject2) {
compared[combinedPath] = true;
}
// End of cyclic logic
// neither value1 nor value2 is a cycle
// continue with next level
return deepEqual(value1, value2, newPath1, newPath2);
});
})(first, second, "$1", "$2");
}
deepEqualCyclic.use = function(match) {
return function(a, b) {
return deepEqualCyclic(a, b, match);
};
};
module.exports = deepEqualCyclic;
},{"./get-class":52,"./get-class-name":51,"./identical":53,"./is-arguments":54,"./is-date":55,"./is-element":56,"./is-nan":57,"./is-object":59,"./is-set":60,"./is-subset":61,"@sinonjs/commons":39}],51:[function(require,module,exports){
"use strict";
var valueToString = require("@sinonjs/commons").valueToString;
var re = /function (\w+)\s*\(/;
function getClassName(value) {
if (value.constructor && "name" in value.constructor) {
return value.constructor.name;
}
if (typeof value.constructor === "function") {
var match = valueToString(value.constructor).match(re);
if (match.length > 1) {
return match[1];
}
}
return null;
}
module.exports = getClassName;
},{"@sinonjs/commons":39}],52:[function(require,module,exports){
"use strict";
var o = Object.prototype;
function getClass(value) {
// Returns the internal [[Class]] by calling Object.prototype.toString
// with the provided value as this. Return value is a string, naming the
// internal class, e.g. "Array"
return o.toString.call(value).split(/[ \]]/)[1];
}
module.exports = getClass;
},{}],53:[function(require,module,exports){
"use strict";
var isNaN = require("./is-nan");
var isNegZero = require("./is-neg-zero");
/**
* @name samsam.equal
* @param Object obj1
* @param Object obj2
*
* Returns ``true`` if two objects are strictly equal. Compared to
* ``===`` there are two exceptions:
*
* - NaN is considered equal to NaN
* - -0 and +0 are not considered equal
*/
function identical(obj1, obj2) {
if (obj1 === obj2 || (isNaN(obj1) && isNaN(obj2))) {
return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2);
}
return false;
}
module.exports = identical;
},{"./is-nan":57,"./is-neg-zero":58}],54:[function(require,module,exports){
"use strict";
var getClass = require("./get-class");
/**
* @name samsam.isArguments
* @param Object object
*
* Returns ``true`` if ``object`` is an ``arguments`` object,
* ``false`` otherwise.
*/
function isArguments(object) {
if (getClass(object) === "Arguments") {
return true;
}
if (
typeof object !== "object" ||
typeof object.length !== "number" ||
getClass(object) === "Array"
) {
return false;
}
if (typeof object.callee === "function") {
return true;
}
try {
object[object.length] = 6;
delete object[object.length];
} catch (e) {
return true;
}
return false;
}
module.exports = isArguments;
},{"./get-class":52}],55:[function(require,module,exports){
"use strict";
function isDate(value) {
return value instanceof Date;
}
module.exports = isDate;
},{}],56:[function(require,module,exports){
"use strict";
var div = typeof document !== "undefined" && document.createElement("div");
/**
* @name samsam.isElement
* @param Object object
*
* Returns ``true`` if ``object`` is a DOM element node. Unlike
* Underscore.js/lodash, this function will return ``false`` if ``object``
* is an *element-like* object, i.e. a regular object with a ``nodeType``
* property that holds the value ``1``.
*/
function isElement(object) {
if (!object || object.nodeType !== 1 || !div) {
return false;
}
try {
object.appendChild(div);
object.removeChild(div);
} catch (e) {
return false;
}
return true;
}
module.exports = isElement;
},{}],57:[function(require,module,exports){
"use strict";
function isNaN(value) {
// Unlike global isNaN, this avoids type coercion
// typeof check avoids IE host object issues, hat tip to
// lodash
var val = value; // JsLint thinks value !== value is "weird"
return typeof value === "number" && value !== val;
}
module.exports = isNaN;
},{}],58:[function(require,module,exports){
"use strict";
/**
* @name samsam.isNegZero
* @param Object value
*
* Returns ``true`` if ``value`` is ``-0``.
*/
function isNegZero(value) {
return value === 0 && 1 / value === -Infinity;
}
module.exports = isNegZero;
},{}],59:[function(require,module,exports){
"use strict";
// Returns true when the value is a regular Object and not a specialized Object
//
// This helps speeding up deepEqual cyclic checks
// The premise is that only Objects are stored in the visited array.
// So if this function returns false, we don't have to do the
// expensive operation of searching for the value in the the array of already
// visited objects
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)
);
}
module.exports = isObject;
},{}],60:[function(require,module,exports){
"use strict";
function isSet(val) {
return (typeof Set !== "undefined" && val instanceof Set) || false;
}
module.exports = isSet;
},{}],61:[function(require,module,exports){
"use strict";
function isSubset(s1, s2, compare) {
var allContained = true;
s1.forEach(function(v1) {
var includes = false;
s2.forEach(function(v2) {
if (compare(v2, v1)) {
includes = true;
}
});
allContained = allContained && includes;
});
return allContained;
}
module.exports = isSubset;
},{}],62:[function(require,module,exports){
"use strict";
var slice = require("@sinonjs/commons").prototypes.string.slice;
var typeOf = require("@sinonjs/commons").typeOf;
var valueToString = require("@sinonjs/commons").valueToString;
module.exports = function iterableToString(obj) {
var representation = "";
function stringify(item) {
return typeof item === "string"
? "'" + item + "'"
: valueToString(item);
}
function mapToString(map) {
/* eslint-disable-next-line local-rules/no-prototype-methods */
map.forEach(function(value, key) {
representation +=
"[" + stringify(key) + "," + stringify(value) + "],";
});
representation = slice(representation, 0, -1);
return representation;
}
function genericIterableToString(iterable) {
/* eslint-disable-next-line local-rules/no-prototype-methods */
iterable.forEach(function(value) {
representation += stringify(value) + ",";
});
representation = slice(representation, 0, -1);
return representation;
}
if (typeOf(obj) === "map") {
return mapToString(obj);
}
return genericIterableToString(obj);
};
},{"@sinonjs/commons":39}],63:[function(require,module,exports){
"use strict";
var valueToString = require("@sinonjs/commons").valueToString;
var deepEqual = require("./deep-equal").use(match); // eslint-disable-line no-use-before-define
var getClass = require("./get-class");
var isDate = require("./is-date");
var isSet = require("./is-set");
var isSubset = require("./is-subset");
var createMatcher = require("./matcher");
function arrayContains(array, subset, compare) {
if (subset.length === 0) {
return true;
}
var i, l, j, k;
for (i = 0, l = array.length; i < l; ++i) {
if (compare(array[i], subset[0])) {
for (j = 0, k = subset.length; j < k; ++j) {
if (i + j >= l) {
return false;
}
if (!compare(array[i + j], subset[j])) {
return false;
}
}
return true;
}
}
return false;
}
/**
* @name samsam.match
* @param Object object
* @param Object matcher
*
* Compare arbitrary value ``object`` with matcher.
*/
function match(object, matcher) {
if (matcher && typeof matcher.test === "function") {
return matcher.test(object);
}
if (typeof matcher === "function") {
return matcher(object) === true;
}
if (typeof matcher === "string") {
matcher = matcher.toLowerCase();
var notNull = typeof object === "string" || !!object;
return (
notNull &&
valueToString(object)
.toLowerCase()
.indexOf(matcher) >= 0
);
}
if (typeof matcher === "number") {
return matcher === object;
}
if (typeof matcher === "boolean") {
return matcher === object;
}
if (typeof matcher === "undefined") {
return typeof object === "undefined";
}
if (matcher === null) {
return object === null;
}
if (object === null) {
return false;
}
if (isSet(object)) {
return isSubset(matcher, object, match);
}
if (getClass(object) === "Array" && getClass(matcher) === "Array") {
return arrayContains(object, matcher, match);
}
if (isDate(matcher)) {
return isDate(object) && object.getTime() === matcher.getTime();
}
if (matcher && typeof matcher === "object") {
if (matcher === object) {
return true;
}
if (typeof object !== "object") {
return false;
}
var prop;
// eslint-disable-next-line guard-for-in
for (prop in matcher) {
var value = object[prop];
if (
typeof value === "undefined" &&
typeof object.getAttribute === "function"
) {
value = object.getAttribute(prop);
}
if (
matcher[prop] === null ||
typeof matcher[prop] === "undefined"
) {
if (value !== matcher[prop]) {
return false;
}
} else if (
typeof value === "undefined" ||
!deepEqual(value, matcher[prop])
) {
return false;
}
}
return true;
}
throw new Error(
"Matcher was not a string, a number, a " +
"function, a boolean or an object"
);
}
Object.keys(createMatcher).forEach(function(key) {
match[key] = createMatcher[key];
});
module.exports = match;
},{"./deep-equal":50,"./get-class":52,"./is-date":55,"./is-set":60,"./is-subset":61,"./matcher":64,"@sinonjs/commons":39}],64:[function(require,module,exports){
"use strict";
var arrayProto = require("@sinonjs/commons").prototypes.array;
var deepEqual = require("./deep-equal").use(match); // eslint-disable-line no-use-before-define
var every = require("@sinonjs/commons").every;
var functionName = require("@sinonjs/commons").functionName;
var get = require("lodash").get;
var iterableToString = require("./iterable-to-string");
var objectProto = require("@sinonjs/commons").prototypes.object;
var stringProto = require("@sinonjs/commons").prototypes.string;
var typeOf = require("@sinonjs/commons").typeOf;
var valueToString = require("@sinonjs/commons").valueToString;
var arrayIndexOf = arrayProto.indexOf;
var arrayEvery = arrayProto.every;
var join = arrayProto.join;
var map = arrayProto.map;
var some = arrayProto.some;
var hasOwnProperty = objectProto.hasOwnProperty;
var isPrototypeOf = objectProto.isPrototypeOf;
var stringIndexOf = stringProto.indexOf;
function assertType(value, type, name) {
var actual = typeOf(value);
if (actual !== type) {
throw new TypeError(
"Expected type of " +
name +
" to be " +
type +
", but was " +
actual
);
}
}
function assertMethodExists(value, method, name, methodPath) {
if (value[method] == null) {
throw new TypeError(
"Expected " + name + " to have method " + methodPath
);
}
}
var matcher = {
toString: function() {
return this.message;
}
};
function isMatcher(object) {
return isPrototypeOf(matcher, object);
}
function matchObject(actual, expectation) {
if (actual === null || actual === undefined) {
return false;
}
return arrayEvery(Object.keys(expectation), function(key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
} else if (typeOf(exp) === "object") {
if (!matchObject(act, exp)) {
return false;
}
} else if (!deepEqual(act, exp)) {
return false;
}
return true;
});
}
var TYPE_MAP = {
function: function(m, expectation, message) {
m.test = expectation;
m.message = message || "match(" + functionName(expectation) + ")";
},
number: function(m, expectation) {
m.test = function(actual) {
// we need type coercion here
return expectation == actual; // eslint-disable-line eqeqeq
};
},
object: function(m, expectation) {
var array = [];
if (typeof expectation.test === "function") {
m.test = function(actual) {
return expectation.test(actual) === true;
};
m.message = "match(" + functionName(expectation.test) + ")";
return m;
}
array = map(Object.keys(expectation), function(key) {
return key + ": " + valueToString(expectation[key]);
});
m.test = function(actual) {
return matchObject(actual, expectation);
};
m.message = "match(" + join(array, ", ") + ")";
return m;
},
regexp: function(m, expectation) {
m.test = function(actual) {
return typeof actual === "string" && expectation.test(actual);
};
},
string: function(m, expectation) {
m.test = function(actual) {
return (
typeof actual === "string" &&
stringIndexOf(actual, expectation) !== -1
);
};
m.message = 'match("' + expectation + '")';
}
};
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (message !== undefined && typeof message !== "string") {
throw new TypeError("Message should be a string");
}
if (arguments.length > 2) {
throw new TypeError(
"Expected 1 or 2 arguments, received " + arguments.length
);
}
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function(actual) {
return deepEqual(actual, expectation);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}
matcher.or = function(m2) {
if (!arguments.length) {
throw new TypeError("Matcher expected");
} else if (!isMatcher(m2)) {
m2 = match(m2);
}
var m1 = this;
var or = Object.create(matcher);
or.test = function(actual) {
return m1.test(actual) || m2.test(actual);
};
or.message = m1.message + ".or(" + m2.message + ")";
return or;
};
matcher.and = function(m2) {
if (!arguments.length) {
throw new TypeError("Matcher expected");
} else if (!isMatcher(m2)) {
m2 = match(m2);
}
var m1 = this;
var and = Object.create(matcher);
and.test = function(actual) {
return m1.test(actual) && m2.test(actual);
};
and.message = m1.message + ".and(" + m2.message + ")";
return and;
};
match.isMatcher = isMatcher;
match.any = match(function() {
return true;
}, "any");
match.defined = match(function(actual) {
return actual !== null && actual !== undefined;
}, "defined");
match.truthy = match(function(actual) {
return !!actual;
}, "truthy");
match.falsy = match(function(actual) {
return !actual;
}, "falsy");
match.same = function(expectation) {
return match(function(actual) {
return expectation === actual;
}, "same(" + valueToString(expectation) + ")");
};
match.in = function(arrayOfExpectations) {
if (typeOf(arrayOfExpectations) !== "array") {
throw new TypeError("array expected");
}
return match(function(actual) {
return some(arrayOfExpectations, function(expectation) {
return expectation === actual;
});
}, "in(" + valueToString(arrayOfExpectations) + ")");
};
match.typeOf = function(type) {
assertType(type, "string", "type");
return match(function(actual) {
return typeOf(actual) === type;
}, 'typeOf("' + type + '")');
};
match.instanceOf = function(type) {
if (
typeof Symbol === "undefined" ||
typeof Symbol.hasInstance === "undefined"
) {
assertType(type, "function", "type");
} else {
assertMethodExists(
type,
Symbol.hasInstance,
"type",
"[Symbol.hasInstance]"
);
}
return match(function(actual) {
return actual instanceof type;
}, "instanceOf(" +
(functionName(type) || Object.prototype.toString.call(type)) +
")");
};
function createPropertyMatcher(propertyTest, messagePrefix) {
return function(property, value) {
assertType(property, "string", "property");
var onlyProperty = arguments.length === 1;
var message = messagePrefix + '("' + property + '"';
if (!onlyProperty) {
message += ", " + valueToString(value);
}
message += ")";
return match(function(actual) {
if (
actual === undefined ||
actual === null ||
!propertyTest(actual, property)
) {
return false;
}
return onlyProperty || deepEqual(actual[property], value);
}, message);
};
}
match.has = createPropertyMatcher(function(actual, property) {
if (typeof actual === "object") {
return property in actual;
}
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function(actual, property) {
return hasOwnProperty(actual, property);
}, "hasOwn");
match.hasNested = function(property, value) {
assertType(property, "string", "property");
var onlyProperty = arguments.length === 1;
var message = 'hasNested("' + property + '"';
if (!onlyProperty) {
message += ", " + valueToString(value);
}
message += ")";
return match(function(actual) {
if (
actual === undefined ||
actual === null ||
get(actual, property) === undefined
) {
return false;
}
return onlyProperty || deepEqual(get(actual, property), value);
}, message);
};
match.every = function(predicate) {
if (!isMatcher(predicate)) {
throw new TypeError("Matcher expected");
}
return match(function(actual) {
if (typeOf(actual) === "object") {
return every(Object.keys(actual), function(key) {
return predicate.test(actual[key]);
});
}
return (
!!actual &&
typeOf(actual.forEach) === "function" &&
every(actual, function(element) {
return predicate.test(element);
})
);
}, "every(" + predicate.message + ")");
};
match.some = function(predicate) {
if (!isMatcher(predicate)) {
throw new TypeError("Matcher expected");
}
return match(function(actual) {
if (typeOf(actual) === "object") {
return !every(Object.keys(actual), function(key) {
return !predicate.test(actual[key]);
});
}
return (
!!actual &&
typeOf(actual.forEach) === "function" &&
!every(actual, function(element) {
return !predicate.test(element);
})
);
}, "some(" + predicate.message + ")");
};
match.array = match.typeOf("array");
match.array.deepEquals = function(expectation) {
return match(function(actual) {
// Comparing lengths is the fastest way to spot a difference before iterating through every item
var sameLength = actual.length === expectation.length;
return (
typeOf(actual) === "array" &&
sameLength &&
every(actual, function(element, index) {
var expected = expectation[index];
return typeOf(expected) === "array" &&
typeOf(element) === "array"
? match.array.deepEquals(expected).test(element)
: deepEqual(expected, element);
})
);
}, "deepEquals([" + iterableToString(expectation) + "])");
};
match.array.startsWith = function(expectation) {
return match(function(actual) {
return (
typeOf(actual) === "array" &&
every(expectation, function(expectedElement, index) {
return actual[index] === expectedElement;
})
);
}, "startsWith([" + iterableToString(expectation) + "])");
};
match.array.endsWith = function(expectation) {
return match(function(actual) {
// This indicates the index in which we should start matching
var offset = actual.length - expectation.length;
return (
typeOf(actual) === "array" &&
every(expectation, function(expectedElement, index) {
return actual[offset + index] === expectedElement;
})
);
}, "endsWith([" + iterableToString(expectation) + "])");
};
match.array.contains = function(expectation) {
return match(function(actual) {
return (
typeOf(actual) === "array" &&
every(expectation, function(expectedElement) {
return arrayIndexOf(actual, expectedElement) !== -1;
})
);
}, "contains([" + iterableToString(expectation) + "])");
};
match.map = match.typeOf("map");
match.map.deepEquals = function mapDeepEquals(expectation) {
return match(function(actual) {
// Comparing lengths is the fastest way to spot a difference before iterating through every item
var sameLength = actual.size === expectation.size;
return (
typeOf(actual) === "map" &&
sameLength &&
every(actual, function(element, key) {
return expectation.has(key) && expectation.get(key) === element;
})
);
}, "deepEquals(Map[" + iterableToString(expectation) + "])");
};
match.map.contains = function mapContains(expectation) {
return match(function(actual) {
return (
typeOf(actual) === "map" &&
every(expectation, function(element, key) {
return actual.has(key) && actual.get(key) === element;
})
);
}, "contains(Map[" + iterableToString(expectation) + "])");
};
match.set = match.typeOf("set");
match.set.deepEquals = function setDeepEquals(expectation) {
return match(function(actual) {
// Comparing lengths is the fastest way to spot a difference before iterating through every item
var sameLength = actual.size === expectation.size;
return (
typeOf(actual) === "set" &&
sameLength &&
every(actual, function(element) {
return expectation.has(element);
})
);
}, "deepEquals(Set[" + iterableToString(expectation) + "])");
};
match.set.contains = function setContains(expectation) {
return match(function(actual) {
return (
typeOf(actual) === "set" &&
every(expectation, function(element) {
return actual.has(element);
})
);
}, "contains(Set[" + iterableToString(expectation) + "])");
};
match.bool = match.typeOf("boolean");
match.number = match.typeOf("number");
match.string = match.typeOf("string");
match.object = match.typeOf("object");
match.func = match.typeOf("function");
match.regexp = match.typeOf("regexp");
match.date = match.typeOf("date");
match.symbol = match.typeOf("symbol");
module.exports = match;
},{"./deep-equal":50,"./iterable-to-string":62,"@sinonjs/commons":39,"lodash":72}],65:[function(require,module,exports){
"use strict";
var identical = require("./identical");
var isArguments = require("./is-arguments");
var isElement = require("./is-element");
var isNegZero = require("./is-neg-zero");
var isSet = require("./is-set");
var match = require("./match");
var deepEqualCyclic = require("./deep-equal").use(match);
var createMatcher = require("./matcher");
module.exports = {
createMatcher: createMatcher,
deepEqual: deepEqualCyclic,
identical: identical,
isArguments: isArguments,
isElement: isElement,
isNegZero: isNegZero,
isSet: isSet,
match: match
};
},{"./deep-equal":50,"./identical":53,"./is-arguments":54,"./is-element":56,"./is-neg-zero":58,"./is-set":60,"./match":63,"./matcher":64}],66:[function(require,module,exports){
// This is free and unencumbered software released into the public domain.
// See LICENSE.md for more information.
var encoding = require("./lib/encoding.js");
module.exports = {
TextEncoder: encoding.TextEncoder,
TextDecoder: encoding.TextDecoder,
};
},{"./lib/encoding.js":68}],67:[function(require,module,exports){
(function(global) {
'use strict';
if (typeof module !== "undefined" && module.exports) {
module.exports = global;
}
global["encoding-indexes"] =
{
"big5":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,17392,19506,17923,17830,17784,160359,19831,17843,162993,19682,163013,15253,18230,18244,19527,19520,148159,144919,160594,159371,159954,19543,172881,18255,17882,19589,162924,19719,19108,18081,158499,29221,154196,137827,146950,147297,26189,22267,null,32149,22813,166841,15860,38708,162799,23515,138590,23204,13861,171696,23249,23479,23804,26478,34195,170309,29793,29853,14453,138579,145054,155681,16108,153822,15093,31484,40855,147809,166157,143850,133770,143966,17162,33924,40854,37935,18736,34323,22678,38730,37400,31184,31282,26208,27177,34973,29772,31685,26498,31276,21071,36934,13542,29636,155065,29894,40903,22451,18735,21580,16689,145038,22552,31346,162661,35727,18094,159368,16769,155033,31662,140476,40904,140481,140489,140492,40905,34052,144827,16564,40906,17633,175615,25281,28782,40907,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,12736,12737,12738,12739,12740,131340,12741,131281,131277,12742,12743,131275,139240,12744,131274,12745,12746,12747,12748,131342,12749,12750,256,193,461,192,274,201,282,200,332,211,465,210,null,7870,null,7872,202,257,225,462,224,593,275,233,283,232,299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,476,252,null,7871,null,7873,234,609,9178,9179,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,172969,135493,null,25866,null,null,20029,28381,40270,37343,null,null,161589,25745,20250,20264,20392,20822,20852,20892,20964,21153,21160,21307,21326,21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,23455,23706,24198,24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,32442,32455,32463,32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,36711,36718,29713,31996,32205,26950,31433,21031,null,null,null,null,37260,30904,37214,32956,null,36107,33014,133607,null,null,32927,40647,19661,40393,40460,19518,171510,159758,40458,172339,13761,null,28314,33342,29977,null,18705,39532,39567,40857,31111,164972,138698,132560,142054,20004,20097,20096,20103,20159,20203,20279,13388,20413,15944,20483,20616,13437,13459,13477,20870,22789,20955,20988,20997,20105,21113,21136,21287,13767,21417,13649,21424,13651,21442,21539,13677,13682,13953,21651,21667,21684,21689,21712,21743,21784,21795,21800,13720,21823,13733,13759,21975,13765,163204,21797,null,134210,134421,151851,21904,142534,14828,131905,36422,150968,169189,16467,164030,30586,142392,14900,18389,164189,158194,151018,25821,134524,135092,134357,135412,25741,36478,134806,134155,135012,142505,164438,148691,null,134470,170573,164073,18420,151207,142530,39602,14951,169460,16365,13574,152263,169940,161992,142660,40302,38933,null,17369,155813,25780,21731,142668,142282,135287,14843,135279,157402,157462,162208,25834,151634,134211,36456,139681,166732,132913,null,18443,131497,16378,22643,142733,null,148936,132348,155799,134988,134550,21881,16571,17338,null,19124,141926,135325,33194,39157,134556,25465,14846,141173,36288,22177,25724,15939,null,173569,134665,142031,142537,null,135368,145858,14738,14854,164507,13688,155209,139463,22098,134961,142514,169760,13500,27709,151099,null,null,161140,142987,139784,173659,167117,134778,134196,157724,32659,135375,141315,141625,13819,152035,134796,135053,134826,16275,134960,134471,135503,134732,null,134827,134057,134472,135360,135485,16377,140950,25650,135085,144372,161337,142286,134526,134527,142417,142421,14872,134808,135367,134958,173618,158544,167122,167321,167114,38314,21708,33476,21945,null,171715,39974,39606,161630,142830,28992,33133,33004,23580,157042,33076,14231,21343,164029,37302,134906,134671,134775,134907,13789,151019,13833,134358,22191,141237,135369,134672,134776,135288,135496,164359,136277,134777,151120,142756,23124,135197,135198,135413,135414,22428,134673,161428,164557,135093,134779,151934,14083,135094,135552,152280,172733,149978,137274,147831,164476,22681,21096,13850,153405,31666,23400,18432,19244,40743,18919,39967,39821,154484,143677,22011,13810,22153,20008,22786,138177,194680,38737,131206,20059,20155,13630,23587,24401,24516,14586,25164,25909,27514,27701,27706,28780,29227,20012,29357,149737,32594,31035,31993,32595,156266,13505,null,156491,32770,32896,157202,158033,21341,34916,35265,161970,35744,36125,38021,38264,38271,38376,167439,38886,39029,39118,39134,39267,170000,40060,40479,40644,27503,63751,20023,131207,38429,25143,38050,null,20539,28158,171123,40870,15817,34959,147790,28791,23797,19232,152013,13657,154928,24866,166450,36775,37366,29073,26393,29626,144001,172295,15499,137600,19216,30948,29698,20910,165647,16393,27235,172730,16931,34319,133743,31274,170311,166634,38741,28749,21284,139390,37876,30425,166371,40871,30685,20131,20464,20668,20015,20247,40872,21556,32139,22674,22736,138678,24210,24217,24514,141074,25995,144377,26905,27203,146531,27903,null,29184,148741,29580,16091,150035,23317,29881,35715,154788,153237,31379,31724,31939,32364,33528,34199,40873,34960,40874,36537,40875,36815,34143,39392,37409,40876,167353,136255,16497,17058,23066,null,null,null,39016,26475,17014,22333,null,34262,149883,33471,160013,19585,159092,23931,158485,159678,40877,40878,23446,40879,26343,32347,28247,31178,15752,17603,143958,141206,17306,17718,null,23765,146202,35577,23672,15634,144721,23928,40882,29015,17752,147692,138787,19575,14712,13386,131492,158785,35532,20404,131641,22975,33132,38998,170234,24379,134047,null,139713,166253,16642,18107,168057,16135,40883,172469,16632,14294,18167,158790,16764,165554,160767,17773,14548,152730,17761,17691,19849,19579,19830,17898,16328,150287,13921,17630,17597,16877,23870,23880,23894,15868,14351,23972,23993,14368,14392,24130,24253,24357,24451,14600,14612,14655,14669,24791,24893,23781,14729,25015,25017,25039,14776,25132,25232,25317,25368,14840,22193,14851,25570,25595,25607,25690,14923,25792,23829,22049,40863,14999,25990,15037,26111,26195,15090,26258,15138,26390,15170,26532,26624,15192,26698,26756,15218,15217,15227,26889,26947,29276,26980,27039,27013,15292,27094,15325,27237,27252,27249,27266,15340,27289,15346,27307,27317,27348,27382,27521,27585,27626,27765,27818,15563,27906,27910,27942,28033,15599,28068,28081,28181,28184,28201,28294,166336,28347,28386,28378,40831,28392,28393,28452,28468,15686,147265,28545,28606,15722,15733,29111,23705,15754,28716,15761,28752,28756,28783,28799,28809,131877,17345,13809,134872,147159,22462,159443,28990,153568,13902,27042,166889,23412,31305,153825,169177,31333,31357,154028,31419,31408,31426,31427,29137,156813,16842,31450,31453,31466,16879,21682,154625,31499,31573,31529,152334,154878,31650,31599,33692,154548,158847,31696,33825,31634,31672,154912,15789,154725,33938,31738,31750,31797,154817,31812,31875,149634,31910,26237,148856,31945,31943,31974,31860,31987,31989,31950,32359,17693,159300,32093,159446,29837,32137,32171,28981,32179,32210,147543,155689,32228,15635,32245,137209,32229,164717,32285,155937,155994,32366,32402,17195,37996,32295,32576,32577,32583,31030,156368,39393,32663,156497,32675,136801,131176,17756,145254,17667,164666,32762,156809,32773,32776,32797,32808,32815,172167,158915,32827,32828,32865,141076,18825,157222,146915,157416,26405,32935,166472,33031,33050,22704,141046,27775,156824,151480,25831,136330,33304,137310,27219,150117,150165,17530,33321,133901,158290,146814,20473,136445,34018,33634,158474,149927,144688,137075,146936,33450,26907,194964,16859,34123,33488,33562,134678,137140,14017,143741,144730,33403,33506,33560,147083,159139,158469,158615,144846,15807,33565,21996,33669,17675,159141,33708,33729,33747,13438,159444,27223,34138,13462,159298,143087,33880,154596,33905,15827,17636,27303,33866,146613,31064,33960,158614,159351,159299,34014,33807,33681,17568,33939,34020,154769,16960,154816,17731,34100,23282,159385,17703,34163,17686,26559,34326,165413,165435,34241,159880,34306,136578,159949,194994,17770,34344,13896,137378,21495,160666,34430,34673,172280,34798,142375,34737,34778,34831,22113,34412,26710,17935,34885,34886,161248,146873,161252,34910,34972,18011,34996,34997,25537,35013,30583,161551,35207,35210,35238,35241,35239,35260,166437,35303,162084,162493,35484,30611,37374,35472,162393,31465,162618,147343,18195,162616,29052,35596,35615,152624,152933,35647,35660,35661,35497,150138,35728,35739,35503,136927,17941,34895,35995,163156,163215,195028,14117,163155,36054,163224,163261,36114,36099,137488,36059,28764,36113,150729,16080,36215,36265,163842,135188,149898,15228,164284,160012,31463,36525,36534,36547,37588,36633,36653,164709,164882,36773,37635,172703,133712,36787,18730,166366,165181,146875,24312,143970,36857,172052,165564,165121,140069,14720,159447,36919,165180,162494,36961,165228,165387,37032,165651,37060,165606,37038,37117,37223,15088,37289,37316,31916,166195,138889,37390,27807,37441,37474,153017,37561,166598,146587,166668,153051,134449,37676,37739,166625,166891,28815,23235,166626,166629,18789,37444,166892,166969,166911,37747,37979,36540,38277,38310,37926,38304,28662,17081,140922,165592,135804,146990,18911,27676,38523,38550,16748,38563,159445,25050,38582,30965,166624,38589,21452,18849,158904,131700,156688,168111,168165,150225,137493,144138,38705,34370,38710,18959,17725,17797,150249,28789,23361,38683,38748,168405,38743,23370,168427,38751,37925,20688,143543,143548,38793,38815,38833,38846,38848,38866,38880,152684,38894,29724,169011,38911,38901,168989,162170,19153,38964,38963,38987,39014,15118,160117,15697,132656,147804,153350,39114,39095,39112,39111,19199,159015,136915,21936,39137,39142,39148,37752,39225,150057,19314,170071,170245,39413,39436,39483,39440,39512,153381,14020,168113,170965,39648,39650,170757,39668,19470,39700,39725,165376,20532,39732,158120,14531,143485,39760,39744,171326,23109,137315,39822,148043,39938,39935,39948,171624,40404,171959,172434,172459,172257,172323,172511,40318,40323,172340,40462,26760,40388,139611,172435,172576,137531,172595,40249,172217,172724,40592,40597,40606,40610,19764,40618,40623,148324,40641,15200,14821,15645,20274,14270,166955,40706,40712,19350,37924,159138,40727,40726,40761,22175,22154,40773,39352,168075,38898,33919,40802,40809,31452,40846,29206,19390,149877,149947,29047,150008,148296,150097,29598,166874,137466,31135,166270,167478,37737,37875,166468,37612,37761,37835,166252,148665,29207,16107,30578,31299,28880,148595,148472,29054,137199,28835,137406,144793,16071,137349,152623,137208,14114,136955,137273,14049,137076,137425,155467,14115,136896,22363,150053,136190,135848,136134,136374,34051,145062,34051,33877,149908,160101,146993,152924,147195,159826,17652,145134,170397,159526,26617,14131,15381,15847,22636,137506,26640,16471,145215,147681,147595,147727,158753,21707,22174,157361,22162,135135,134056,134669,37830,166675,37788,20216,20779,14361,148534,20156,132197,131967,20299,20362,153169,23144,131499,132043,14745,131850,132116,13365,20265,131776,167603,131701,35546,131596,20120,20685,20749,20386,20227,150030,147082,20290,20526,20588,20609,20428,20453,20568,20732,20825,20827,20829,20830,28278,144789,147001,147135,28018,137348,147081,20904,20931,132576,17629,132259,132242,132241,36218,166556,132878,21081,21156,133235,21217,37742,18042,29068,148364,134176,149932,135396,27089,134685,29817,16094,29849,29716,29782,29592,19342,150204,147597,21456,13700,29199,147657,21940,131909,21709,134086,22301,37469,38644,37734,22493,22413,22399,13886,22731,23193,166470,136954,137071,136976,23084,22968,37519,23166,23247,23058,153926,137715,137313,148117,14069,27909,29763,23073,155267,23169,166871,132115,37856,29836,135939,28933,18802,37896,166395,37821,14240,23582,23710,24158,24136,137622,137596,146158,24269,23375,137475,137476,14081,137376,14045,136958,14035,33066,166471,138682,144498,166312,24332,24334,137511,137131,23147,137019,23364,34324,161277,34912,24702,141408,140843,24539,16056,140719,140734,168072,159603,25024,131134,131142,140827,24985,24984,24693,142491,142599,149204,168269,25713,149093,142186,14889,142114,144464,170218,142968,25399,173147,25782,25393,25553,149987,142695,25252,142497,25659,25963,26994,15348,143502,144045,149897,144043,21773,144096,137433,169023,26318,144009,143795,15072,16784,152964,166690,152975,136956,152923,152613,30958,143619,137258,143924,13412,143887,143746,148169,26254,159012,26219,19347,26160,161904,138731,26211,144082,144097,26142,153714,14545,145466,145340,15257,145314,144382,29904,15254,26511,149034,26806,26654,15300,27326,14435,145365,148615,27187,27218,27337,27397,137490,25873,26776,27212,15319,27258,27479,147392,146586,37792,37618,166890,166603,37513,163870,166364,37991,28069,28427,149996,28007,147327,15759,28164,147516,23101,28170,22599,27940,30786,28987,148250,148086,28913,29264,29319,29332,149391,149285,20857,150180,132587,29818,147192,144991,150090,149783,155617,16134,16049,150239,166947,147253,24743,16115,29900,29756,37767,29751,17567,159210,17745,30083,16227,150745,150790,16216,30037,30323,173510,15129,29800,166604,149931,149902,15099,15821,150094,16127,149957,149747,37370,22322,37698,166627,137316,20703,152097,152039,30584,143922,30478,30479,30587,149143,145281,14942,149744,29752,29851,16063,150202,150215,16584,150166,156078,37639,152961,30750,30861,30856,30930,29648,31065,161601,153315,16654,31131,33942,31141,27181,147194,31290,31220,16750,136934,16690,37429,31217,134476,149900,131737,146874,137070,13719,21867,13680,13994,131540,134157,31458,23129,141045,154287,154268,23053,131675,30960,23082,154566,31486,16889,31837,31853,16913,154547,155324,155302,31949,150009,137136,31886,31868,31918,27314,32220,32263,32211,32590,156257,155996,162632,32151,155266,17002,158581,133398,26582,131150,144847,22468,156690,156664,149858,32733,31527,133164,154345,154947,31500,155150,39398,34373,39523,27164,144447,14818,150007,157101,39455,157088,33920,160039,158929,17642,33079,17410,32966,33033,33090,157620,39107,158274,33378,33381,158289,33875,159143,34320,160283,23174,16767,137280,23339,137377,23268,137432,34464,195004,146831,34861,160802,23042,34926,20293,34951,35007,35046,35173,35149,153219,35156,161669,161668,166901,166873,166812,166393,16045,33955,18165,18127,14322,35389,35356,169032,24397,37419,148100,26068,28969,28868,137285,40301,35999,36073,163292,22938,30659,23024,17262,14036,36394,36519,150537,36656,36682,17140,27736,28603,140065,18587,28537,28299,137178,39913,14005,149807,37051,37015,21873,18694,37307,37892,166475,16482,166652,37927,166941,166971,34021,35371,38297,38311,38295,38294,167220,29765,16066,149759,150082,148458,16103,143909,38543,167655,167526,167525,16076,149997,150136,147438,29714,29803,16124,38721,168112,26695,18973,168083,153567,38749,37736,166281,166950,166703,156606,37562,23313,35689,18748,29689,147995,38811,38769,39224,134950,24001,166853,150194,38943,169178,37622,169431,37349,17600,166736,150119,166756,39132,166469,16128,37418,18725,33812,39227,39245,162566,15869,39323,19311,39338,39516,166757,153800,27279,39457,23294,39471,170225,19344,170312,39356,19389,19351,37757,22642,135938,22562,149944,136424,30788,141087,146872,26821,15741,37976,14631,24912,141185,141675,24839,40015,40019,40059,39989,39952,39807,39887,171565,39839,172533,172286,40225,19630,147716,40472,19632,40204,172468,172269,172275,170287,40357,33981,159250,159711,158594,34300,17715,159140,159364,159216,33824,34286,159232,145367,155748,31202,144796,144960,18733,149982,15714,37851,37566,37704,131775,30905,37495,37965,20452,13376,36964,152925,30781,30804,30902,30795,137047,143817,149825,13978,20338,28634,28633,28702,28702,21524,147893,22459,22771,22410,40214,22487,28980,13487,147884,29163,158784,151447,23336,137141,166473,24844,23246,23051,17084,148616,14124,19323,166396,37819,37816,137430,134941,33906,158912,136211,148218,142374,148417,22932,146871,157505,32168,155995,155812,149945,149899,166394,37605,29666,16105,29876,166755,137375,16097,150195,27352,29683,29691,16086,150078,150164,137177,150118,132007,136228,149989,29768,149782,28837,149878,37508,29670,37727,132350,37681,166606,166422,37766,166887,153045,18741,166530,29035,149827,134399,22180,132634,134123,134328,21762,31172,137210,32254,136898,150096,137298,17710,37889,14090,166592,149933,22960,137407,137347,160900,23201,14050,146779,14000,37471,23161,166529,137314,37748,15565,133812,19094,14730,20724,15721,15692,136092,29045,17147,164376,28175,168164,17643,27991,163407,28775,27823,15574,147437,146989,28162,28428,15727,132085,30033,14012,13512,18048,16090,18545,22980,37486,18750,36673,166940,158656,22546,22472,14038,136274,28926,148322,150129,143331,1358 | |