CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...function CustomEvent(type, customData, target) {
this.initEvent(type, false, false, target);
this.detail = customData.detail || null;
}n/a
Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...function ProgressEvent(type, progressEventRaw, target) {
this.initEvent(type, false, false, target);
this.loaded = typeof progressEventRaw.loaded === "number" ? progressEventRaw.loaded : null;
this.total = typeof progressEventRaw.total === "number" ? progressEventRaw.total : null;
this.lengthComputable = !!progressEventRaw.total;
}n/a
addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...calledInOrder = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
configureLogError = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
deepEqual = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Fixed deepEqual to detect properties on array objects
* Fixed problem with chained timers with delay=0 (Ian Lewis)
* Use formatio in place of buster-format (Devin Weaver)
== 1.7.3 / 2013-06-20
* Removed use of array forEach, breaks in older browsers (Martin Hansen)
* sinon.deepEqual(new Date(0), new Date()) returns true (G.Serebryanskyi)
== 1.7.2 / 2013-05-08
* Sinon 1.7 has split calls out to a separate file. This caused some problems,
so 1.7.2 ships with spyCall as part of spy.js like it used to be.
== 1.7.1 / 2013-05-07
...every = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
function matchObject(expectation, actual) {
if (actual === null || actual === undefined) {
return false;
}
return Object.keys(expectation).every(function (key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
...extend = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
format = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Ensure sinon can run in a WebWorker
* Updated docs to reflect that calledOn accepts a matcher
* simplified test and added a note
* updated to require spy in its new cjs form
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
...functionName = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
functionToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
getConfig = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Breaking change: thisObj -> thisValue
Change brings consistency to the code-base, always use thisValue
* Add sinon.assert.pass callback for successful assertions
* Extract sandbox configuration from sinon.test
Refactored sinon.test to not do all the heavy lifting in creating sandbox
objects from sinon.config. Now sinon.sandbox.create accepts an optional
configuration that can be retrieved through sinon.getConfig({ ... }) - or, to
match previous behavior, through sinon.getConfig(sinon.config);
The default configuration now lives in sinon.defaultConfig rather than the
previous sinon.test.
This change enables external tools, such as test framework adapters, to easily
create configurable sandboxes without going through sinon.test
...getPropertyDescriptor = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
iterableToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
orderByFirstCall = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
restore = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...:(
n/a
function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...timesInWords = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
typeOf = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...walk = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
wrapMethod = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...function CustomEvent(type, customData, target) {
this.initEvent(type, false, false, target);
this.detail = customData.detail || null;
}n/a
function Function() { [native code] }n/a
Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...initEvent = function (type, bubbles, cancelable, target) {
this.type = type;
this.bubbles = bubbles;
this.cancelable = cancelable;
this.target = target;
}...
},{"./get-property-descriptor":31,"./value-to-string":39}],42:[function(require,module,exports){
"use strict";
var push = [].push;
function Event(type, bubbles, cancelable, target) {
this.initEvent(type, bubbles, cancelable, target);
}
Event.prototype = {
initEvent: function (type, bubbles, cancelable, target) {
this.type = type;
this.bubbles = bubbles;
this.cancelable = cancelable;
...preventDefault = function () {
this.defaultPrevented = true;
}n/a
stopPropagation = function () {}n/a
addEventListener = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Add spy.calledWithNew to check if a function was used as a constructor
* Add spy.notCalledWith(), spy.neverCalledWith() and
sinon.assert.neverCalledWith. By Max Antoni
* Publicly expose sinon.expectation.fail to allow tools to integrate with mock
expectations.
* Fake XMLHttpRequests now support a minimal portion of the events API, making
them work seamlessly with e.g. SproutCode (which uses
xhr.addEventListener("readystatechange"). Partially by Sven Fuchs.
== 1.1.1 / 2011-05-17
* Fix broken mock verification in CommonJS when not including the full Sinon
package.
== 1.1.0 / 2011-05-04
* The fake server now has a autoRespond method which allows it to respond to
...dispatchEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...removeEventListener = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
function addFilter(fn) {
this.filters.push(fn);
}n/a
function defake(fakeXhr, xhrArgs) {
var xhr = new sinonXhr.workingXHR(); // eslint-disable-line new-cap
[
"open",
"setRequestHeader",
"send",
"abort",
"getResponseHeader",
"getAllResponseHeaders",
"addEventListener",
"overrideMimeType",
"removeEventListener"
].forEach(function (method) {
fakeXhr[method] = function () {
return apply(xhr, method, arguments);
};
});
var copyAttrs = function (args) {
args.forEach(function (attr) {
fakeXhr[attr] = xhr[attr];
});
};
var stateChange = function stateChange() {
fakeXhr.readyState = xhr.readyState;
if (xhr.readyState >= FakeXMLHttpRequest.HEADERS_RECEIVED) {
copyAttrs(["status", "statusText"]);
}
if (xhr.readyState >= FakeXMLHttpRequest.LOADING) {
copyAttrs(["responseText", "response"]);
}
if (xhr.readyState === FakeXMLHttpRequest.DONE) {
copyAttrs(["responseXML"]);
}
if (fakeXhr.onreadystatechange) {
fakeXhr.onreadystatechange.call(fakeXhr, { target: fakeXhr });
}
};
if (xhr.addEventListener) {
Object.keys(fakeXhr.eventListeners).forEach(function (event) {
/*eslint-disable no-loop-func*/
fakeXhr.eventListeners[event].forEach(function (handler) {
xhr.addEventListener(event, handler);
});
/*eslint-enable no-loop-func*/
});
xhr.addEventListener("readystatechange", stateChange);
} else {
xhr.onreadystatechange = stateChange;
}
apply(xhr, "open", xhrArgs);
}...
if (FakeXMLHttpRequest.useFilters === true) {
var xhrArgs = arguments;
var defake = FakeXMLHttpRequest.filters.some(function (filter) {
return filter.apply(this, xhrArgs);
});
if (defake) {
FakeXMLHttpRequest.defake(this, arguments);
return;
}
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
...function parseXML(text) {
// Treat empty string as parsing failure
if (text !== "") {
try {
if (typeof DOMParser !== "undefined") {
var parser = new DOMParser();
return parser.parseFromString(text, "text/xml");
}
var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(text);
return xmlDoc;
} catch (e) {
// Unable to parse XML - no biggie
}
}
return null;
}...
var blobOptions = {};
if (contentType) {
blobOptions.type = contentType;
}
return new Blob([convertToArrayBuffer(body)], blobOptions);
} else if (responseType === "document") {
if (isXmlContentType(contentType)) {
return FakeXMLHttpRequest.parseXML(body);
}
return null;
}
throw new Error("Invalid responseType " + responseType);
}
function clearResponse(xhr) {
...function abort() {
this.aborted = true;
clearResponse(this);
this.errorFlag = true;
this.requestHeaders = {};
this.responseHeaders = {};
if (this.readyState !== FakeXMLHttpRequest.UNSENT && this.sendFlag
&& this.readyState !== FakeXMLHttpRequest.DONE) {
this.readyStateChange(FakeXMLHttpRequest.DONE);
this.sendFlag = false;
}
this.readyState = FakeXMLHttpRequest.UNSENT;
}...
* Previous expectation failures are checked and re-thrown again in mock.verify()
* Expose XHR.setStatus to simplify asynchronous answers
* Fix typo
* Add a how-to article about using links seams for CommonJS modules
* stub() will fail if passed an empty property descriptor
* Rename func argument to funcOrDescriptor
* Add documentation for sinon.assert.match
* XHR: test for readystatechange not dispatching after .abort() in DONE state
* XHR: fix readystatechange event after .abort() in DONE state
* Add tests for xhr.readyState after abort()
* Test that demonstrates that a mock can be called more times than expected without failing (if the exception is silenced).
n.n.n / 2017-02-27
==================
...function addEventListener(event, listener) {
this.eventListeners = this.eventListeners || {};
this.eventListeners[event] = this.eventListeners[event] || [];
push.call(this.eventListeners[event], listener);
}...
* Add spy.calledWithNew to check if a function was used as a constructor
* Add spy.notCalledWith(), spy.neverCalledWith() and
sinon.assert.neverCalledWith. By Max Antoni
* Publicly expose sinon.expectation.fail to allow tools to integrate with mock
expectations.
* Fake XMLHttpRequests now support a minimal portion of the events API, making
them work seamlessly with e.g. SproutCode (which uses
xhr.addEventListener("readystatechange"). Partially by Sven Fuchs.
== 1.1.1 / 2011-05-17
* Fix broken mock verification in CommonJS when not including the full Sinon
package.
== 1.1.0 / 2011-05-04
* The fake server now has a autoRespond method which allows it to respond to
...function dispatchEvent(event) {
var self = this;
var type = event.type;
var listeners = self.eventListeners && self.eventListeners[type] || [];
listeners.forEach(function (listener) {
if (typeof listener === "function") {
listener.call(self, event);
} else {
listener.handleEvent(event);
}
});
return !!event.defaultPrevented;
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...function downloadProgress(progressEventRaw) {
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
}n/a
error = function () {
clearResponse(this);
this.errorFlag = true;
this.requestHeaders = {};
this.responseHeaders = {};
this.readyStateChange(FakeXMLHttpRequest.DONE);
}n/a
function getAllResponseHeaders() {
if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) {
return "";
}
var responseHeaders = this.responseHeaders;
var headers = Object.keys(responseHeaders)
.filter(excludeSetCookie2Header)
.reduce(function (prev, header) {
var value = responseHeaders[header];
return prev + (header + ": " + value + "\r\n");
}, "");
return headers;
}n/a
function getResponseHeader(header) {
if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) {
return null;
}
if (/^Set-Cookie2?$/i.test(header)) {
return null;
}
header = getHeader(this.responseHeaders, header);
return this.responseHeaders[header] || null;
}...
return headers;
},
setResponseBody: function setResponseBody(body) {
verifyRequestSent(this);
verifyHeadersReceived(this);
verifyResponseBodyType(body);
var contentType = this.overriddenMimeType || this.getResponseHeader("Content-Type
");
var isTextResponse = this.responseType === "" || this.responseType === "text";
clearResponse(this);
if (this.async) {
var chunkSize = this.chunkSize || 10;
var index = 0;
...function open(method, url, async, username, password) {
this.method = method;
this.url = url;
this.async = typeof async === "boolean" ? async : true;
this.username = username;
this.password = password;
clearResponse(this);
this.requestHeaders = {};
this.sendFlag = false;
if (FakeXMLHttpRequest.useFilters === true) {
var xhrArgs = arguments;
var defake = FakeXMLHttpRequest.filters.some(function (filter) {
return filter.apply(this, xhrArgs);
});
if (defake) {
FakeXMLHttpRequest.defake(this, arguments);
return;
}
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
}n/a
function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
this.overriddenMimeType = type;
}n/a
function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false, false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
}
}
if (this.readyState === FakeXMLHttpRequest.DONE) {
if (this.aborted || this.status === 0) {
progress = {loaded: 0, total: 0};
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(readyStateChangeEvent);
}...
return filter.apply(this, xhrArgs);
});
if (defake) {
FakeXMLHttpRequest.defake(this, arguments);
return;
}
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false, false, this);
var event, progress;
...function removeEventListener(event, listener) {
var listeners = this.eventListeners && this.eventListeners[event] || [];
var index = listeners.indexOf(listener);
if (index === -1) {
return;
}
listeners.splice(index, 1);
}n/a
function respond(status, headers, body) {
this.setStatus(status);
this.setResponseHeaders(headers || {});
this.setResponseBody(body || "");
}...
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
* added timeouts to ensure tests pass
* Run tests on stable Node 6 instead of unstable Node 5
* added tests to ensure only expected events are fired (#1043)
...function send(data) {
verifyState(this);
if (!/^(head)$/i.test(this.method)) {
var contentType = getHeader(this.requestHeaders, "Content-Type");
if (this.requestHeaders[contentType]) {
var value = this.requestHeaders[contentType].split(";");
this.requestHeaders[contentType] = value[0] + ";charset=utf-8";
} else if (supportsFormData && !(data instanceof FormData)) {
this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8";
}
this.requestBody = data;
}
this.errorFlag = false;
this.sendFlag = this.async;
clearResponse(this);
this.readyStateChange(FakeXMLHttpRequest.OPENED);
if (typeof this.onSend === "function") {
this.onSend(this);
}
this.dispatchEvent(new sinonEvent.Event("loadstart", false, false, this));
}n/a
function setRequestHeader(header, value) {
verifyState(this);
var checkUnsafeHeaders = true;
if (typeof this.unsafeHeadersEnabled === "function") {
checkUnsafeHeaders = this.unsafeHeadersEnabled();
}
if (checkUnsafeHeaders && (unsafeHeaders[header] || /^(Sec-|Proxy-)/.test(header))) {
throw new Error("Refused to set unsafe header \"" + header + "\"");
}
if (this.requestHeaders[header]) {
this.requestHeaders[header] += "," + value;
} else {
this.requestHeaders[header] = value;
}
}n/a
function setResponseBody(body) {
verifyRequestSent(this);
verifyHeadersReceived(this);
verifyResponseBodyType(body);
var contentType = this.overriddenMimeType || this.getResponseHeader("Content-Type");
var isTextResponse = this.responseType === "" || this.responseType === "text";
clearResponse(this);
if (this.async) {
var chunkSize = this.chunkSize || 10;
var index = 0;
do {
this.readyStateChange(FakeXMLHttpRequest.LOADING);
if (isTextResponse) {
this.responseText = this.response += body.substring(index, index + chunkSize);
}
index += chunkSize;
} while (index < body.length);
}
this.response = convertResponseBody(this.responseType, contentType, body);
if (isTextResponse) {
this.responseText = this.response;
}
if (this.responseType === "document") {
this.responseXML = this.response;
} else if (this.responseType === "" && isXmlContentType(contentType)) {
this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText);
}
this.readyStateChange(FakeXMLHttpRequest.DONE);
}...
}
this.readyStateChange(FakeXMLHttpRequest.DONE);
},
respond: function respond(status, headers, body) {
this.setStatus(status);
this.setResponseHeaders(headers || {});
this.setResponseBody(body || "");
},
uploadProgress: function uploadProgress(progressEventRaw) {
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
...function setResponseHeaders(headers) {
verifyRequestOpened(this);
var responseHeaders = this.responseHeaders = {};
Object.keys(headers).forEach(function (header) {
responseHeaders[header] = headers[header];
});
if (this.async) {
this.readyStateChange(FakeXMLHttpRequest.HEADERS_RECEIVED);
} else {
this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED;
}
}...
this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText);
}
this.readyStateChange(FakeXMLHttpRequest.DONE);
},
respond: function respond(status, headers, body) {
this.setStatus(status);
this.setResponseHeaders(headers || {});
this.setResponseBody(body || "");
},
uploadProgress: function uploadProgress(progressEventRaw) {
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
...function setStatus(status) {
var sanitizedStatus = typeof status === "number" ? status : 200;
verifyRequestOpened(this);
this.status = sanitizedStatus;
this.statusText = FakeXMLHttpRequest.statusCodes[sanitizedStatus];
}...
} else if (this.responseType === "" && isXmlContentType(contentType)) {
this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText);
}
this.readyStateChange(FakeXMLHttpRequest.DONE);
},
respond: function respond(status, headers, body) {
this.setStatus(status);
this.setResponseHeaders(headers || {});
this.setResponseBody(body || "");
},
uploadProgress: function uploadProgress(progressEventRaw) {
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
...function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail: error}));
}
}n/a
function uploadProgress(progressEventRaw) {
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...function ProgressEvent(type, progressEventRaw, target) {
this.initEvent(type, false, false, target);
this.loaded = typeof progressEventRaw.loaded === "number" ? progressEventRaw.loaded : null;
this.total = typeof progressEventRaw.total === "number" ? progressEventRaw.total : null;
this.lengthComputable = !!progressEventRaw.total;
}n/a
function Function() { [native code] }n/a
alwaysCalledOn = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
alwaysCalledWith = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
alwaysCalledWithExactly = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
alwaysCalledWithMatch = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
alwaysCalledWithNew = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
alwaysThrew = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
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");
}
}n/a
function assertCallOrder() {
verifyIsStub.apply(null, arguments);
var expected = "";
var actual = "";
if (!calledInOrder(arguments)) {
try {
expected = [].join.call(arguments, ", ");
var calls = slice.call(arguments);
var i = calls.length;
while (i) {
if (!calls[--i].called) {
calls.splice(i, 1);
}
}
actual = orderByFirstCall(calls).join(", ");
} 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");
}
}n/a
called = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledOn = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledOnce = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledThrice = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledTwice = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledWith = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}...
== 1.14.0 / 2015-03-13
* Stub & spy getters & setters (Simon Zack)
* Fix #702 async sinon.test using mocha interface (Mohayonao)
* Add respondImmediately to fake servers (Jonathan Freeman)
== 1.13.0 / 2015-03-04
* fix @depends-require mismatches (fixes AMD issues) (Ben Hockey)
* Fix spy.calledWith(undefined) to return false if it was called without args
* yieldsRight (Alexander Schmidt)
* stubs retain function arity (Charlie Rudolph)
* (AMD) use explicit define in built version
* spy().reset() returns this (Ali Shakiba)
* Add lengthComputable and download progress (Tamas Szebeni)
* Don't setContent-type when sending FormData (AJ Ortega)
* sinon.assert with spyCall (Alex Urbano)
...calledWithExactly = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledWithMatch = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
calledWithNew = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}...
if (matching) {
returnValue = matching.invoke(func, thisValue, args);
} else {
returnValue = (this.func || func).apply(thisValue, args);
}
var thisCall = this.getCall(this.callCount - 1);
if (thisCall.calledWithNew() && typeof returnValue !== "object"
;) {
returnValue = thisValue;
}
} catch (e) {
exception = e;
} finally {
delete this.invoking;
}
...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" || !!o.includeFail;
var instance = this;
Object.keys(instance).forEach(function (method) {
if (method !== "expose" && (includeFail || !/^(fail)/.test(method))) {
target[exposedName(prefix, method)] = instance[method];
}
});
return target;
}n/a
function fail(message) {
var error = new Error(message);
error.name = this.failException || assert.failException;
throw error;
}...
var assert;
function verifyIsStub() {
var args = Array.prototype.slice.call(arguments);
args.forEach(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");
...function match(actual, expectation) {
var matcher = sinonMatch(expectation);
if (matcher.test(actual)) {
assert.pass("match");
} else {
var formatted = [
"expected value to match",
" expected = " + format(expectation),
" actual = " + format(actual)
];
failAssertion(this, formatted.join("\n"));
}
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...neverCalledWith = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}...
method directly inside Sinon.
* Bug fix: Don't assume that req.requestBody is a string in the fake server.
* Added spy.printf(format) to print a nicely formatted message with details
about a spy.
* Garbage collection: removing fakes from collections when restoring the
original methods. Fix by Tristan Koch.
* Add spy.calledWithNew to check if a function was used as a constructor
* Add spy.notCalledWith(), spy.neverCalledWith() and
sinon.assert.neverCalledWith. By Max Antoni
* Publicly expose sinon.expectation.fail to allow tools to integrate with mock
expectations.
* Fake XMLHttpRequests now support a minimal portion of the events API, making
them work seamlessly with e.g. SproutCode (which uses
xhr.addEventListener("readystatechange"). Partially by Sven Fuchs.
...neverCalledWithMatch = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
notCalled = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
function pass() {}...
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
};
}
function exposedName(prefix, prop) {
return !prefix || /^fail/.test(prop) ? prop :
prefix + prop.slice(0, 1).toUpperCase() + prop.slice(1);
...threw = function (fake) {
verifyIsStub(fake);
var args = slice.call(arguments, 1);
var failed = false;
verifyIsValidAssertion(name, args);
if (typeof method === "function") {
failed = !method(fake);
} else {
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
}n/a
function addBehavior(stub, name, fn) {
proto[name] = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
};
stub[name] = createBehavior(name);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...callThrough = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
* Merge pull request #1289 from mroderick/fix-invalid-release-version-in-docs
Fix invalid release number in v1.17.7.md front matter
* Merge pull request #1290 from sinonjs/common-eslint
Use common Sinon.JS eslint config
* Merge pull request #1288 from mroderick/improve-documentation
Improve documentation
* Merge pull request #1283 from lucasfcosta/docs-stub-callThrough
Add docs for stub.callThrough()
* Merge pull request #1285 from sinonjs/uncycle-server-deps
Uncycle server deps
* Merge pull request #1282 from sinonjs/mochify-3
Use mocaccino 2 and mochify 3
* Merge pull request #1281 from mroderick/add-missing-documentation
Add missing documentation
* Merge pull request #1277 from mroderick/remove-copyright-comments
...callsArg = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgOn = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgOnAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgOnWith = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgOnWithAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgWith = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsArgWithAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
callsFake = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
* Merge pull request #1203 from jdgreenberger/add-expectation-diff-logs
Add expectation diff logs
* Merge pull request #1208 from lucasfcosta/array-matchers
Array matchers
* Merge pull request #1209 from lucasfcosta/avoid-unnecessary-empty-stub-creation
Avoid unnecessary empty stub creation
* Merge pull request #1207 from hurrymaplelad/calls-fake
Replace `stub(o, 'm', fn)` with `stub(o, 'm').callsFake(fn)`
* Merge pull request #1162 from dottedmag/master
XHR spec conformance: abort() should not dispatch
readystatechange event in DONE state
* Merge pull request #1184 from mroderick/fail-on-empty-property-descriptor
Fail on empty property descriptor
* Merge pull request #1206 from fatso83/sinon-format-docs
Update format docs to refer to formatio
...function create(stub) {
var behavior = extend({}, proto);
delete behavior.create;
delete behavior.addBehavior;
delete behavior.createBehavior;
behavior.stub = stub;
return behavior;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
};
}...
Object.keys(behavior).forEach(function (method) {
if (behavior.hasOwnProperty(method) &&
!proto.hasOwnProperty(method) &&
method !== "create" &&
method !== "withArgs" &&
method !== "invoke") {
proto[method] = behavior.createBehavior(method);
}
});
Object.keys(behaviors).forEach(function (method) {
if (behaviors.hasOwnProperty(method) && !proto.hasOwnProperty(method)) {
behavior.addBehavior(stub, method, behaviors[method]);
}
...get = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
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) {
...function invoke(context, args) {
callCallback(this, args);
if (this.exception) {
throw this.exception;
} else if (typeof this.returnArgAt === "number") {
return args[this.returnArgAt];
} else if (this.returnThis) {
return context;
} else if (this.fakeFn) {
return this.fakeFn.apply(context, args);
} else if (this.resolve) {
return Promise.resolve(this.returnValue);
} else if (this.reject) {
return Promise.reject(this.returnValue);
} else if (this.callsThrough) {
return this.stub.wrappedMethod.apply(context, args);
}
return this.returnValue;
}...
// 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.call(arguments
)); }; break;
case 2: p = function proxy(a, b) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 3: p = function proxy(a, b, c) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 4: p = function proxy(a, b, c, d) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 5: p = function proxy(a, b, c, d, e) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 6: p = function proxy(a, b, c, d, e, f) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 7: p = function proxy(a, b, c, d, e, f, g) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 8: p = function proxy(a, b, c, d, e, f, g, h) { return p.invoke(func, this, slice.call(arguments)); }; break;
...function isPresent() {
return (typeof this.callArgAt === "number" ||
this.exception ||
typeof this.returnArgAt === "number" ||
this.returnThis ||
this.fakeFn ||
this.returnValueDefined);
}...
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) {
...function onCall(index) {
return this.stub.onCall(index);
}...
} else if (this.callsThrough) {
return this.stub.wrappedMethod.apply(context, args);
}
return this.returnValue;
},
onCall: function onCall(index) {
return this.stub.onCall(index);
},
onFirstCall: function onFirstCall() {
return this.stub.onFirstCall();
},
onSecondCall: function onSecondCall() {
...function onFirstCall() {
return this.stub.onFirstCall();
}...
},
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() {
...function onSecondCall() {
return this.stub.onSecondCall();
}...
},
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 */) {
...function onThirdCall() {
return this.stub.onThirdCall();
}...
},
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."
...rejects = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...resolves = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...returns = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
returnsArg = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
* Stubs now work for inherited methods. This was previously prohibited to avoid
stubbing not-yet-implemented methods. (Felix Geisendörfer)
* server.respond() can now accept the same arguments as server.respondWith() for
quick-and-dirty respondWith+respond. (Gavin Huang)
* Format objects with buster-format in the default bundle. Default to
util.inspect on node unless buster-format is available (not a hard dependency,
...returnsThis = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}...
falsy} as well as typeOf shortcuts for boolean, number, string, object,
function, array, regexp and date. The result of a call can be used with
spy.calledWith.
* spy.returned now works with matchers and compares objects deeply.
* Matcher assertions: calledWithMatch, alwaysCalledWithMatch and
neverCalledWithMatch
* calledWithNew and alwaysCalledWithNew for assert (Maximilian Antoni)
* Easier stubbed fluent interfaces: stub.returnsThis() (Glen Mailer)
* allow yields() and family to be used along with returns()/throws() and
family (Glen Mailer)
* Async versions `callsArg*` and `yields*` for stubs (TEHEK)
* Format args when doing `spy.printf("%*")` (Domenic Denicola)
* Add notCalled property to spies
* Fix: spy.reset did not reset fakes created by spy.withArgs (Maximilian Antoni)
* Properly restore stubs when stubbing entire objects through the sandbox
...set = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
throws = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
throwsException = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
function withArgs() {
throw new Error(
"Defining a stub by invoking \"stub.onCall(...).withArgs(...)\" " +
"is not supported. Use \"stub.withArgs(...).onCall(...)\" " +
"to define sequential behavior for calls with certain arguments."
);
}...
onThirdCall: function onThirdCall() {
return this.stub.onThirdCall();
},
withArgs: function withArgs(/* arguments */) {
throw new Error(
"Defining a stub by invoking \"stub.onCall(...).withArgs(...)\
x22; " +
"is not supported. Use \"stub.withArgs(...).onCall(...)\" " +
"to define sequential behavior for calls with certain arguments."
);
}
};
function createAsyncVersion(syncFnName) {
...yields = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsOn = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsOnAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsRight = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsRightAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsTo = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsToAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsToOn = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
yieldsToOnAsync = function () {
fn.apply(this, [this].concat([].slice.call(arguments)));
return this.stub || this;
}n/a
create = function (now) {
return llx.createClock(now);
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...function add(fake) {
push.call(getFakes(this), fake);
return fake;
}...
add: function add(fake) {
push.call(getFakes(this), fake);
return fake;
},
spy: function spy() {
return this.add(sinonSpy.apply(sinonSpy, arguments));
},
stub: function stub(object, property/*, value*/) {
throwOnFalsyObject.apply(null, arguments);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isStubbingNonFunctionProperty = property && typeof object[property] !== "function";
...function inject(obj) {
var col = this;
obj.spy = function () {
return col.spy.apply(col, arguments);
};
obj.stub = function () {
return col.stub.apply(col, arguments);
};
obj.mock = function () {
return col.mock.apply(col, arguments);
};
return obj;
}...
return Object.create(sinonSandbox);
}
var sandbox = prepareSandboxFromConfig(config);
sandbox.args = sandbox.args || [];
sandbox.injectedKeys = [];
sandbox.injectInto = config.injectInto;
var exposed = sandbox.inject({});
if (config.properties) {
config.properties.forEach(function (prop) {
var value = exposed[prop] || prop === "sandbox" && sandbox;
exposeValue(sandbox, config, prop, value);
});
} else {
...function mock() {
return this.add(sinonMock.apply(null, arguments));
}n/a
function reset() {
each(this, "reset");
}...
* CJSify get-config tests (#1081)
* CJSify sinon.assert tests (#1078)
* Resolve test failure in node 0.10.x (#1073)
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
...function resetBehavior() {
each(this, "resetBehavior");
}...
delete this.returnValue;
delete this.returnArgAt;
delete this.fakeFn;
this.returnThis = false;
fakes.forEach(function (fake) {
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
...function resetHistory() {
each(this, "resetHistory");
}...
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
this.resetBehavior();
},
onCall: function onCall(index) {
if (!this.behaviors[index]) {
this.behaviors[index] = behavior.create(this);
}
...function restore() {
each(this, "restore");
this.fakes = [];
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy() {
return this.add(sinonSpy.apply(sinonSpy, arguments));
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...function stub(object, property) {
throwOnFalsyObject.apply(null, arguments);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isStubbingNonFunctionProperty = property && typeof object[property] !== "function";
var stubbed = isStubbingNonFunctionProperty ?
stubNonFunctionProperty.apply(null, arguments) :
sinonStub.apply(null, arguments);
if (isStubbingEntireObject) {
collectOwnMethods(stubbed).forEach(this.add.bind(this));
} else {
this.add(stubbed);
}
return stubbed;
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...function verify() {
each(this, "verify");
}...
* Update docs and migration guide
* Convert 3 arg stub to callsFake
* Update format docs to refer to formatio
* Fix being able to spy Error
* Prepare documentation using site in GitHub Pages
* Add link to LICENSE in README.md
* Add documentation for accessor method support for stubs and spies
* Previous expectation failures are checked and re-thrown again in mock.verify()
* Expose XHR.setStatus to simplify asynchronous answers
* Fix typo
* Add a how-to article about using links seams for CommonJS modules
* stub() will fail if passed an empty property descriptor
* Rename func argument to funcOrDescriptor
* Add documentation for sinon.assert.match
* XHR: test for readystatechange not dispatching after .abort() in DONE state
...function verifyAndRestore() {
var exception;
try {
this.verify();
} catch (e) {
exception = e;
}
this.restore();
if (exception) {
throw exception;
}
}n/a
green = function (str) {
return colorize(str, 32);
}...
var jsDiff = require("diff");
var push = Array.prototype.push;
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
if (calledArgMessage) {
calledArgMessage = color.green(calledArgMessage);
}
}
return calledArgMessage + " " + matcher.message;
}
function colorDiffText(diff) {
var objects = diff.map(function (part) {
...red = function (str) {
return colorize(str, 31);
}...
var sinonFormat = require("./util/core/format");
var sinonMatch = require("./match");
var jsDiff = require("diff");
var push = Array.prototype.push;
function colorSinonMatchText(matcher, calledArg, calledArgMessage) {
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
if (calledArgMessage) {
calledArgMessage = color.green(calledArgMessage);
}
}
return calledArgMessage + " " + matcher.message;
}
...function callThrough(fake) {
fake.callsThrough = true;
}...
* Merge pull request #1289 from mroderick/fix-invalid-release-version-in-docs
Fix invalid release number in v1.17.7.md front matter
* Merge pull request #1290 from sinonjs/common-eslint
Use common Sinon.JS eslint config
* Merge pull request #1288 from mroderick/improve-documentation
Improve documentation
* Merge pull request #1283 from lucasfcosta/docs-stub-callThrough
Add docs for stub.callThrough()
* Merge pull request #1285 from sinonjs/uncycle-server-deps
Uncycle server deps
* Merge pull request #1282 from sinonjs/mochify-3
Use mocaccino 2 and mochify 3
* Merge pull request #1281 from mroderick/add-missing-documentation
Add missing documentation
* Merge pull request #1277 from mroderick/remove-copyright-comments
...function callsArg(fake, pos) {
if (typeof pos !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = pos;
fake.callbackArguments = [];
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
callsArgAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
function callsArgOn(fake, pos, context) {
if (typeof pos !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = pos;
fake.callbackArguments = [];
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
callsArgOnAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
function callsArgWith(fake, pos, context) {
if (typeof pos !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = pos;
fake.callbackArguments = slice.call(arguments, 3);
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
callsArgOnWithAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
function callsArgWith(fake, pos) {
if (typeof pos !== "number") {
throw new TypeError("argument index is not number");
}
fake.callArgAt = pos;
fake.callbackArguments = slice.call(arguments, 2);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
callsArgWithAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
function callsFake(fake, fn) {
fake.fakeFn = fn;
}...
* Merge pull request #1203 from jdgreenberger/add-expectation-diff-logs
Add expectation diff logs
* Merge pull request #1208 from lucasfcosta/array-matchers
Array matchers
* Merge pull request #1209 from lucasfcosta/avoid-unnecessary-empty-stub-creation
Avoid unnecessary empty stub creation
* Merge pull request #1207 from hurrymaplelad/calls-fake
Replace `stub(o, 'm', fn)` with `stub(o, 'm').callsFake(fn)`
* Merge pull request #1162 from dottedmag/master
XHR spec conformance: abort() should not dispatch
readystatechange event in DONE state
* Merge pull request #1184 from mroderick/fail-on-empty-property-descriptor
Fail on empty property descriptor
* Merge pull request #1206 from fatso83/sinon-format-docs
Update format docs to refer to formatio
...function get(fake, getterFunction) {
var rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, {
get: getterFunction
});
return fake;
}...
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) {
...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.reject = true;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.fakeFn = undefined;
return fake;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...function resolves(fake, value) {
fake.returnValue = value;
fake.resolve = true;
fake.reject = false;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.fakeFn = undefined;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...function returns(fake, value) {
fake.returnValue = value;
fake.resolve = false;
fake.reject = false;
fake.returnValueDefined = true;
fake.exception = undefined;
fake.fakeFn = undefined;
}n/a
function returnsArg(fake, pos) {
if (typeof pos !== "number") {
throw new TypeError("argument index is not number");
}
fake.returnArgAt = pos;
}...
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
* Stubs now work for inherited methods. This was previously prohibited to avoid
stubbing not-yet-implemented methods. (Felix Geisendörfer)
* server.respond() can now accept the same arguments as server.respondWith() for
quick-and-dirty respondWith+respond. (Gavin Huang)
* Format objects with buster-format in the default bundle. Default to
util.inspect on node unless buster-format is available (not a hard dependency,
...function returnsThis(fake) {
fake.returnThis = true;
}...
falsy} as well as typeOf shortcuts for boolean, number, string, object,
function, array, regexp and date. The result of a call can be used with
spy.calledWith.
* spy.returned now works with matchers and compares objects deeply.
* Matcher assertions: calledWithMatch, alwaysCalledWithMatch and
neverCalledWithMatch
* calledWithNew and alwaysCalledWithNew for assert (Maximilian Antoni)
* Easier stubbed fluent interfaces: stub.returnsThis() (Glen Mailer)
* allow yields() and family to be used along with returns()/throws() and
family (Glen Mailer)
* Async versions `callsArg*` and `yields*` for stubs (TEHEK)
* Format args when doing `spy.printf("%*")` (Domenic Denicola)
* Add notCalled property to spies
* Fix: spy.reset did not reset fakes created by spy.withArgs (Maximilian Antoni)
* Properly restore stubs when stubbing entire objects through the sandbox
...function set(fake, setterFunction) {
var rootStub = fake.stub || fake;
Object.defineProperty(rootStub.rootObj, rootStub.propName, { // eslint-disable-line accessor-pairs
set: setterFunction
});
return fake;
}n/a
function throwsException(fake, error, message) {
if (typeof error === "string") {
fake.exception = new Error(message || "");
fake.exception.name = error;
} else if (!error) {
fake.exception = new Error("Error");
} else {
fake.exception = error;
}
}n/a
function throwsException(fake, error, message) {
if (typeof error === "string") {
fake.exception = new Error(message || "");
fake.exception.name = error;
} else if (!error) {
fake.exception = new Error("Error");
} else {
fake.exception = error;
}
}n/a
yields = function (fake) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice.call(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
yieldsAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
yieldsOn = function (fake, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice.call(arguments, 2);
fake.callbackContext = context;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
yieldsOnAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
yieldsRight = function (fake) {
fake.callArgAt = useRightMostCallback;
fake.callbackArguments = slice.call(arguments, 1);
fake.callbackContext = undefined;
fake.callArgProp = undefined;
fake.callbackAsync = false;
}n/a
yieldsRightAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
yieldsTo = function (fake, prop) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice.call(arguments, 2);
fake.callbackContext = undefined;
fake.callArgProp = prop;
fake.callbackAsync = false;
}n/a
yieldsToAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
yieldsToOn = function (fake, prop, context) {
fake.callArgAt = useLeftMostCallback;
fake.callbackArguments = slice.call(arguments, 3);
fake.callbackContext = context;
fake.callArgProp = prop;
fake.callbackAsync = false;
}n/a
yieldsToOnAsync = function () {
var result = module.exports[syncFnName].apply(this, arguments);
this.callbackAsync = true;
return result;
}n/a
function CustomEvent(type, customData, target) {
this.initEvent(type, false, false, target);
this.detail = customData.detail || null;
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...function Event(type, bubbles, cancelable, target) {
this.initEvent(type, bubbles, cancelable, target);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function ProgressEvent(type, progressEventRaw, target) {
this.initEvent(type, false, false, target);
this.loaded = typeof progressEventRaw.loaded === "number" ? progressEventRaw.loaded : null;
this.total = typeof progressEventRaw.total === "number" ? progressEventRaw.total : null;
this.lengthComputable = !!progressEventRaw.total;
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...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;
}
args = args || [];
if (args.length < expectedArguments.length) {
return false;
}
if (this.expectsExactArgCount &&
args.length !== expectedArguments.length) {
return false;
}
return expectedArguments.every(function (expectedArgument, i) {
if (!verifyMatcher(expectedArgument, args[i])) {
return false;
}
if (!deepEqual(expectedArgument, args[i])) {
return false;
}
return true;
});
}...
var expectationsWithMatchingArgs = expectations.filter(function (expectation) {
var expectedArgs = expectation.expectedArguments || [];
return arrayEquals(expectedArgs, currentArgs, expectation.expectsExactArgCount);
});
var expectationsToApply = expectationsWithMatchingArgs.filter(function (expectation) {
return !expectation.met() && expectation.allowsCall(thisValue, args);
});
if (expectationsToApply.length > 0) {
return expectationsToApply[0].apply(thisValue, args);
}
var messages = [];
...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;
}...
},
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);
},
...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;
}...
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) {
...function create(methodName) {
var expectation = extend(stub.create(), mockExpectation);
delete expectation.create;
expectation.method = methodName;
return expectation;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...function exactly(num) {
if (typeof num !== "number") {
throw new TypeError("'" + valueToString(num) + "' is not a number");
}
this.atLeast(num);
return this.atMost(num);
}...
this.maxCalls = num;
return this;
},
never: function never() {
return this.exactly(0);
},
once: function once() {
return this.exactly(1);
},
twice: function twice() {
...function fail(message) {
var exception = new Error(message);
exception.name = "ExpectationError";
throw exception;
}...
var assert;
function verifyIsStub() {
var args = Array.prototype.slice.call(arguments);
args.forEach(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");
...function invoke(func, thisValue, args) {
this.verifyCallAllowed(thisValue, args);
return spyInvoke.apply(this, arguments);
}...
// 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.call(arguments
)); }; break;
case 2: p = function proxy(a, b) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 3: p = function proxy(a, b, c) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 4: p = function proxy(a, b, c, d) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 5: p = function proxy(a, b, c, d, e) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 6: p = function proxy(a, b, c, d, e, f) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 7: p = function proxy(a, b, c, d, e, f, g) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 8: p = function proxy(a, b, c, d, e, f, g, h) { return p.invoke(func, this, slice.call(arguments)); }; break;
...function met() {
return !this.failed && receivedMinCalls(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;
}
...function never() {
return this.exactly(0);
}n/a
function on(thisValue) {
this.expectedThis = thisValue;
return this;
}n/a
function once() {
return this.exactly(1);
}n/a
function pass(message) {
assert.pass(message);
}...
failed = typeof fake[method] === "function" ?
!fake[method].apply(fake, args) : !fake[method];
}
if (failed) {
failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args)));
} else {
assert.pass(name);
}
};
}
function exposedName(prefix, prop) {
return !prefix || /^fail/.test(prop) ? prop :
prefix + prop.slice(0, 1).toUpperCase() + prop.slice(1);
...function thrice() {
return this.exactly(3);
}n/a
toString = function () {
var args = (this.expectedArguments || []).slice();
if (!this.expectsExactArgCount) {
push.call(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) + ")";
}...
"' since no callback was passed.", args);
}
yieldFn.apply(thisValue, slice.call(arguments, 2));
},
toString: function () {
var callStr = this.proxy ? this.proxy.toString() + "(" : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = slice.call(this.args).map(function (arg) {
...function twice() {
return this.exactly(2);
}n/a
function verify() {
if (!this.met()) {
mockExpectation.fail(this.toString());
} else {
mockExpectation.pass(this.toString());
}
return true;
}...
* Update docs and migration guide
* Convert 3 arg stub to callsFake
* Update format docs to refer to formatio
* Fix being able to spy Error
* Prepare documentation using site in GitHub Pages
* Add link to LICENSE in README.md
* Add documentation for accessor method support for stubs and spies
* Previous expectation failures are checked and re-thrown again in mock.verify()
* Expose XHR.setStatus to simplify asynchronous answers
* Fix typo
* Add a how-to article about using links seams for CommonJS modules
* stub() will fail if passed an empty property descriptor
* Rename func argument to funcOrDescriptor
* Add documentation for sinon.assert.match
* XHR: test for readystatechange not dispatching after .abort() in DONE state
...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));
}
expectedArguments.forEach(function (expectedArgument, i) {
if (!verifyMatcher(expectedArgument, args[i])) {
mockExpectation.fail(this.method + " received wrong arguments " + format(args) +
", didn't match " + expectedArguments.toString());
}
if (!deepEqual(expectedArgument, args[i])) {
mockExpectation.fail(this.method + " received wrong arguments " + format(args) +
", expected " + format(expectedArguments));
}
});
}...
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");
...function withArgs() {
this.expectedArguments = slice.call(arguments);
return this;
}...
onThirdCall: function onThirdCall() {
return this.stub.onThirdCall();
},
withArgs: function withArgs(/* arguments */) {
throw new Error(
"Defining a stub by invoking \"stub.onCall(...).withArgs(...)\
x22; " +
"is not supported. Use \"stub.withArgs(...).onCall(...)\" " +
"to define sequential behavior for calls with certain arguments."
);
}
};
function createAsyncVersion(syncFnName) {
...function withExactArgs() {
this.withArgs.apply(this, arguments);
this.expectsExactArgCount = true;
return this;
}n/a
function addRequest(xhrObj) {
var server = this;
push.call(this.requests, xhrObj);
incrementRequestCount.call(this);
xhrObj.onSend = function () {
server.handleRequest(this);
if (server.respondImmediately) {
server.respond();
} else if (server.autoRespond && !server.responding) {
setTimeout(function () {
server.responding = false;
server.respond();
}, server.autoRespondAfter || 10);
server.responding = true;
}
};
}...
server.requests = [];
server.requestCount = 0;
this.xhr.onCreate = function (xhrObj) {
xhrObj.unsafeHeadersEnabled = function () {
return !(server.unsafeHeadersEnabled === false);
};
server.addRequest(xhrObj);
};
return server;
},
configure: function (config) {
var self = this;
...configure = function (config) {
var self = this;
var whitelist = {
"autoRespond": true,
"autoRespondAfter": true,
"respondImmediately": true,
"fakeHTTPMethods": true,
"logger": true,
"unsafeHeadersEnabled": true
};
config = config || {};
Object.keys(config).forEach(function (setting) {
if (setting in whitelist) {
self[setting] = config[setting];
}
});
self.logError = configureLogError(config);
}...
};
},{}],27:[function(require,module,exports){
"use strict";
var formatio = require("formatio");
var formatter = formatio.configure({
quoteStrings: false,
limitChildrenCount: 250
});
module.exports = function format() {
return formatter.ascii.apply(formatter, arguments);
};
...create = function (config) {
var server = Object.create(this);
server.configure(config);
this.xhr = fakeXhr.useFakeXMLHttpRequest();
server.requests = [];
server.requestCount = 0;
this.xhr.onCreate = function (xhrObj) {
xhrObj.unsafeHeadersEnabled = function () {
return !(server.unsafeHeadersEnabled === false);
};
server.addRequest(xhrObj);
};
return server;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...function getHTTPMethod(request) {
if (this.fakeHTTPMethods && /post/i.test(request.method)) {
var matches = (request.requestBody || "").match(/_method=([^\b;]+)/);
return matches ? matches[1] : request.method;
}
return request.method;
}...
function match(response, request) {
var requestUrl = request.url;
if (!/^https?:\/\//.test(requestUrl) || rCurrLoc.test(requestUrl)) {
requestUrl = requestUrl.replace(rCurrLoc, "");
}
if (matchOne(response, this.getHTTPMethod(request), requestUrl)) {
if (typeof response.response === "function") {
var ru = response.url;
var args = [request].concat(ru && typeof ru.exec === "function" ? ru.exec(requestUrl).slice(1) : []);
return response.response.apply(response, args);
}
return true;
...function getRequest(index) {
return this.requests[index] || null;
}...
this.requested = true;
this.requestedOnce = count === 1;
this.requestedTwice = count === 2;
this.requestedThrice = count === 3;
this.firstRequest = this.getRequest(0);
this.secondRequest = this.getRequest(1);
this.thirdRequest = this.getRequest(2);
this.lastRequest = this.getRequest(count - 1);
}
var fakeServer = {
...function handleRequest(xhr) {
if (xhr.async) {
if (!this.queue) {
this.queue = [];
}
push.call(this.queue, xhr);
} else {
this.processRequest(xhr);
}
}...
addRequest: function addRequest(xhrObj) {
var server = this;
push.call(this.requests, xhrObj);
incrementRequestCount.call(this);
xhrObj.onSend = function () {
server.handleRequest(this);
if (server.respondImmediately) {
server.respond();
} else if (server.autoRespond && !server.responding) {
setTimeout(function () {
server.responding = false;
server.respond();
...function log(response, request) {
var str;
str = "Request:\n" + format(request) + "\n\n";
str += "Response:\n" + format(response) + "\n\n";
if (typeof this.logger === "function") {
this.logger(str);
}
}...
exports.printWarning = function (msg) {
// Watch out for IE7 and below! :(
if (typeof console !== "undefined") {
if (console.info) {
console.info(msg);
} else {
console.log(msg);
}
}
};
},{}],25:[function(require,module,exports){
"use strict";
...function logError(label, e) {
var msg = label + " threw exception: ";
var err = { name: e.name || label, message: e.message || e.toString(), stack: e.stack };
function throwLoggedError() {
err.message = msg + err.message;
throw err;
}
config.logger(msg + "[" + err.name + "] " + err.message);
if (err.stack) {
config.logger(err.stack);
}
if (config.useImmediateExceptions) {
throwLoggedError();
} else {
config.setTimeout(throwLoggedError, 0);
}
}...
if (request.readyState !== 4) {
this.log(response, request);
request.respond(response[0], response[1], response[2]);
}
} catch (e) {
this.logError("Fake server request processing", e);
}
},
restore: function restore() {
return this.xhr.restore && this.xhr.restore.apply(this.xhr, arguments);
},
...logger = function () {
// no-op; override via configure()
}...
var err = { name: e.name || label, message: e.message || e.toString(), stack: e.stack };
function throwLoggedError() {
err.message = msg + err.message;
throw err;
}
config.logger(msg + "[" + err.name + "] " + err.message);
if (err.stack) {
config.logger(err.stack);
}
if (config.useImmediateExceptions) {
throwLoggedError();
...function processRequest(request) {
try {
if (request.aborted) {
return;
}
var response = this.response || [404, {}, ""];
if (this.responses) {
for (var l = this.responses.length, i = l - 1; i >= 0; i--) {
if (match.call(this, this.responses[i], request)) {
response = this.responses[i].response;
break;
}
}
}
if (request.readyState !== 4) {
this.log(response, request);
request.respond(response[0], response[1], response[2]);
}
} catch (e) {
this.logError("Fake server request processing", e);
}
}...
if (xhr.async) {
if (!this.queue) {
this.queue = [];
}
push.call(this.queue, xhr);
} else {
this.processRequest(xhr);
}
},
logger: function () {
// no-op; override via configure()
},
...function reset() {
this.resetBehavior();
this.resetHistory();
}...
* CJSify get-config tests (#1081)
* CJSify sinon.assert tests (#1078)
* Resolve test failure in node 0.10.x (#1073)
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
...function resetBehavior() {
this.responses.length = this.queue.length = 0;
}...
delete this.returnValue;
delete this.returnArgAt;
delete this.fakeFn;
this.returnThis = false;
fakes.forEach(function (fake) {
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
...function resetHistory() {
this.requests.length = this.requestCount = 0;
this.requestedOnce = this.requestedTwice = this.requestedThrice = this.requested = false;
this.firstRequest = this.secondRequest = this.thirdRequest = this.lastRequest = null;
}...
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
this.resetBehavior();
},
onCall: function onCall(index) {
if (!this.behaviors[index]) {
this.behaviors[index] = behavior.create(this);
}
...function respond() {
if (arguments.length > 0) {
this.respondWith.apply(this, arguments);
}
var queue = this.queue || [];
var requests = queue.splice(0, queue.length);
var self = this;
requests.forEach(function (request) {
self.processRequest(request);
});
}...
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
* added timeouts to ensure tests pass
* Run tests on stable Node 6 instead of unstable Node 5
* added tests to ensure only expected events are fired (#1043)
...function respondWith(method, url, body) {
if (arguments.length === 1 && typeof method !== "function") {
this.response = responseArray(method);
return;
}
if (!this.responses) {
this.responses = [];
}
if (arguments.length === 1) {
body = method;
url = method = null;
}
if (arguments.length === 2) {
body = url;
url = method;
method = null;
}
push.call(this.responses, {
method: method,
url: typeof url === "string" && url !== "" ? pathToRegexp(url) : url,
response: typeof body === "function" ? body : responseArray(body)
});
}...
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
* Stubs now work for inherited methods. This was previously prohibited to avoid
stubbing not-yet-implemented methods. (Felix Geisendörfer)
* server.respond() can now accept the same arguments as server.respondWith() for
quick-and-dirty respondWith+respond. (Gavin Huang)
* Format objects with buster-format in the default bundle. Default to
util.inspect on node unless buster-format is available (not a hard dependency,
more like a 'preference').
* Bug fix: Make sure XHRs can complete even if onreadystatechange handler fails
* Bug fix: Mirror entire Date.prototype, including toUTCString when faking
...function restore() {
return this.xhr.restore && this.xhr.restore.apply(this.xhr, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function addRequest(xhr) {
if (xhr.async) {
if (typeof setTimeout.clock === "object") {
this.clock = setTimeout.clock;
} else {
this.clock = fakeTimers.useFakeTimers();
this.resetClock = true;
}
if (!this.longestTimeout) {
var clockSetTimeout = this.clock.setTimeout;
var clockSetInterval = this.clock.setInterval;
var server = this;
this.clock.setTimeout = function (fn, timeout) {
server.longestTimeout = Math.max(timeout, server.longestTimeout || 0);
return clockSetTimeout.apply(this, arguments);
};
this.clock.setInterval = function (fn, timeout) {
server.longestTimeout = Math.max(timeout, server.longestTimeout || 0);
return clockSetInterval.apply(this, arguments);
};
}
}
return fakeServer.addRequest.call(this, xhr);
}...
server.requests = [];
server.requestCount = 0;
this.xhr.onCreate = function (xhrObj) {
xhrObj.unsafeHeadersEnabled = function () {
return !(server.unsafeHeadersEnabled === false);
};
server.addRequest(xhrObj);
};
return server;
},
configure: function (config) {
var self = this;
...function respond() {
var returnVal = fakeServer.respond.apply(this, arguments);
if (this.clock) {
this.clock.tick(this.longestTimeout || 0);
this.longestTimeout = 0;
if (this.resetClock) {
this.clock.restore();
this.resetClock = false;
}
}
return returnVal;
}...
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
* added timeouts to ensure tests pass
* Run tests on stable Node 6 instead of unstable Node 5
* added tests to ensure only expected events are fired (#1043)
...function restore() {
if (this.clock) {
this.clock.restore();
}
return fakeServer.restore.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...has = 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(value, actual[property]);
}, message);
}...
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) {
...hasOwn = 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(value, actual[property]);
}, message);
}n/a
instanceOf = function (type) {
assertType(type, "function", "type");
return match(function (actual) {
return actual instanceof type;
}, "instanceOf(" + functionName(type) + ")");
}n/a
function isMatcher(object) {
return matcher.isPrototypeOf(object);
}...
msg += " Received [" + slice.call(args).join(", ") + "]";
}
throw new Error(msg);
}
var callProto = {
calledOn: function calledOn(thisValue) {
if (sinonMatch && sinonMatch.isMatcher(thisValue)) {
return thisValue.test(this.thisValue);
}
return this.thisValue === thisValue;
},
calledWith: function calledWith() {
var self = this;
...same = function (expectation) {
return match(function (actual) {
return expectation === actual;
}, "same(" + valueToString(expectation) + ")");
}n/a
typeOf = function (type) {
assertType(type, "string", "type");
return match(function (actual) {
return typeOf(actual) === type;
}, "typeOf(\"" + type + "\")");
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...test = function () {
return true;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...contains = function (expectation) {
return match(function (actual) {
return typeOf(actual) === "array" && every(expectation, function (expectedElement) {
return indexOf.call(actual, expectedElement) !== -1;
});
}, "contains([" + iterableToString(expectation) + "])");
}n/a
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) {
return expectation[index] === element;
});
}, "deepEquals([" + iterableToString(expectation) + "])");
}n/a
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) + "])");
}n/a
startsWith = function (expectation) {
return match(function (actual) {
return typeOf(actual) === "array" && every(expectation, function (expectedElement, index) {
return actual[index] === expectedElement;
});
}, "startsWith([" + iterableToString(expectation) + "])");
}n/a
test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return actual !== null && actual !== undefined;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return !actual;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...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) + "])");
}n/a
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) + "])");
}n/a
test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...function setContains(expectation) {
return match(function (actual) {
return typeOf(actual) === "set" && every(expectation, function (element) {
return actual.has(element);
});
}, "contains(Set[" + iterableToString(expectation) + "])");
}n/a
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) + "])");
}n/a
test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return typeOf(actual) === type;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...test = function (actual) {
return !!actual;
}...
* Improve Blob support detection logics
* Fix a typo in Contributing.md
* Update Node versions on Travis
* Use PhantomJS 2.
* Fix #835: make err.message writable
* Remove linting errors in switch cases
* Add spy.notCalled to documentation
* Remove `sinon.test()` and `sinon.testCase`.
* Remove `sinon.log` and `sinon.logError`
* De-fluff
* Remove `sinon-test` module.
* Extract `get-config` tests from `sinon-test`.
* Extract `function-to-string` tests from `sinon-test`.
* Extract `restore` tests from `sinon-test`.
* Extract `createStubInstance` tests from `sinon-test`
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
function create(object) {
if (!object) {
throw new TypeError("object is null");
}
var mockObject = extend({}, mock);
mockObject.object = object;
delete mockObject.create;
return mockObject;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...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.call(this.proxies, method);
}
var expectation = mockExpectation.create(method);
push.call(this.expectations[method], expectation);
return expectation;
}n/a
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 = expectations.filter(function (expectation) {
var expectedArgs = expectation.expectedArguments || [];
return arrayEquals(expectedArgs, currentArgs, expectation.expectsExactArgCount);
});
var expectationsToApply = expectationsWithMatchingArgs.filter(function (expectation) {
return !expectation.met() && expectation.allowsCall(thisValue, args);
});
if (expectationsToApply.length > 0) {
return expectationsToApply[0].apply(thisValue, args);
}
var messages = [];
var exhausted = 0;
expectationsWithMatchingArgs.forEach(function (expectation) {
if (expectation.allowsCall(thisValue, args)) {
available = available || expectation;
} else {
exhausted += 1;
}
});
if (available && exhausted === 0) {
return available.apply(thisValue, args);
}
expectations.forEach(function (expectation) {
push.call(messages, " " + expectation.toString());
});
messages.unshift("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 */}
}
this.failures.push("Unexpected call: " + spyCallToString.call({
proxy: method,
args: args,
stack: err.stack
}));
mockExpectation.fail(messages.join("\n"));
}...
}
if (!this.expectations[method]) {
this.expectations[method] = [];
var mockObject = this;
wrapMethod(this.object, method, function () {
return mockObject.invokeMethod(method, this, arguments);
});
push.call(this.proxies, method);
}
var expectation = mockExpectation.create(method);
push.call(this.expectations[method], expectation);
...function restore() {
var object = this.object;
each(this.proxies, function (proxy) {
if (typeof object[proxy].restore === "function") {
object[proxy].restore();
}
});
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function verify() {
var expectations = this.expectations || {};
var messages = this.failures ? this.failures.slice() : [];
var met = [];
each(this.proxies, function (proxy) {
each(expectations[proxy], function (expectation) {
if (!expectation.met()) {
push.call(messages, expectation.toString());
} else {
push.call(met, expectation.toString());
}
});
});
this.restore();
if (messages.length > 0) {
mockExpectation.fail(messages.concat(met).join("\n"));
} else if (met.length > 0) {
mockExpectation.pass(messages.concat(met).join("\n"));
}
return true;
}...
* Update docs and migration guide
* Convert 3 arg stub to callsFake
* Update format docs to refer to formatio
* Fix being able to spy Error
* Prepare documentation using site in GitHub Pages
* Add link to LICENSE in README.md
* Add documentation for accessor method support for stubs and spies
* Previous expectation failures are checked and re-thrown again in mock.verify()
* Expose XHR.setStatus to simplify asynchronous answers
* Fix typo
* Add a how-to article about using links seams for CommonJS modules
* stub() will fail if passed an empty property descriptor
* Rename func argument to funcOrDescriptor
* Add documentation for sinon.assert.match
* XHR: test for readystatechange not dispatching after .abort() in DONE state
...create = function (config) {
if (!config) {
return Object.create(sinonSandbox);
}
var sandbox = prepareSandboxFromConfig(config);
sandbox.args = sandbox.args || [];
sandbox.injectedKeys = [];
sandbox.injectInto = config.injectInto;
var exposed = sandbox.inject({});
if (config.properties) {
config.properties.forEach(function (prop) {
var value = exposed[prop] || prop === "sandbox" && sandbox;
exposeValue(sandbox, config, prop, value);
});
} else {
exposeValue(sandbox, config, "sandbox");
}
return sandbox;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...inject = function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
obj.clock = this.clock;
}
if (this.server) {
obj.server = this.server;
obj.requests = this.server.requests;
}
obj.match = sinonMatch;
return obj;
}...
return Object.create(sinonSandbox);
}
var sandbox = prepareSandboxFromConfig(config);
sandbox.args = sandbox.args || [];
sandbox.injectedKeys = [];
sandbox.injectInto = config.injectInto;
var exposed = sandbox.inject({});
if (config.properties) {
config.properties.forEach(function (prop) {
var value = exposed[prop] || prop === "sandbox" && sandbox;
exposeValue(sandbox, config, prop, value);
});
} else {
...function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...restore = function () {
if (arguments.length) {
throw new Error("sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()");
}
sinonCollection.restore.apply(this, arguments);
this.restoreContext();
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...restoreContext = function () {
var injectedKeys = this.injectedKeys;
var injectInto = this.injectInto;
if (!injectedKeys) {
return;
}
injectedKeys.forEach(function (injectedKey) {
delete injectInto[injectedKey];
});
injectedKeys = [];
}...
restore: function () {
if (arguments.length) {
throw new Error("sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()");
}
sinonCollection.restore.apply(this, arguments);
this.restoreContext();
},
restoreContext: function () {
var injectedKeys = this.injectedKeys;
var injectInto = this.injectInto;
if (!injectedKeys) {
...function useFakeServer() {
var proto = this.serverPrototype || fakeServer;
if (!proto || !proto.create) {
return null;
}
this.server = proto.create();
return this.add(this.server);
}...
var sandbox = Object.create(sinonSandbox);
if (config.useFakeServer) {
if (typeof config.useFakeServer === "object") {
sandbox.serverPrototype = config.useFakeServer;
}
sandbox.useFakeServer();
}
if (config.useFakeTimers) {
if (typeof config.useFakeTimers === "object") {
sandbox.useFakeTimers.apply(sandbox, config.useFakeTimers);
} else {
sandbox.useFakeTimers();
...function useFakeTimers() {
this.clock = sinonClock.useFakeTimers.apply(null, arguments);
return this.add(this.clock);
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...calledInOrder = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
configureLogError = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
deepEqual = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Fixed deepEqual to detect properties on array objects
* Fixed problem with chained timers with delay=0 (Ian Lewis)
* Use formatio in place of buster-format (Devin Weaver)
== 1.7.3 / 2013-06-20
* Removed use of array forEach, breaks in older browsers (Martin Hansen)
* sinon.deepEqual(new Date(0), new Date()) returns true (G.Serebryanskyi)
== 1.7.2 / 2013-05-08
* Sinon 1.7 has split calls out to a separate file. This caused some problems,
so 1.7.2 ships with spyCall as part of spy.js like it used to be.
== 1.7.1 / 2013-05-07
...every = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
function matchObject(expectation, actual) {
if (actual === null || actual === undefined) {
return false;
}
return Object.keys(expectation).every(function (key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
...extend = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
format = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Ensure sinon can run in a WebWorker
* Updated docs to reflect that calledOn accepts a matcher
* simplified test and added a note
* updated to require spy in its new cjs form
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
...functionName = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
functionToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
getConfig = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Breaking change: thisObj -> thisValue
Change brings consistency to the code-base, always use thisValue
* Add sinon.assert.pass callback for successful assertions
* Extract sandbox configuration from sinon.test
Refactored sinon.test to not do all the heavy lifting in creating sandbox
objects from sinon.config. Now sinon.sandbox.create accepts an optional
configuration that can be retrieved through sinon.getConfig({ ... }) - or, to
match previous behavior, through sinon.getConfig(sinon.config);
The default configuration now lives in sinon.defaultConfig rather than the
previous sinon.test.
This change enables external tools, such as test framework adapters, to easily
create configurable sandboxes without going through sinon.test
...getPropertyDescriptor = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
iterableToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
orderByFirstCall = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
restore = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...:(
n/a
function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...timesInWords = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
typeOf = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...walk = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
wrapMethod = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...calledInOrder = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
configureLogError = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
deepEqual = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Fixed deepEqual to detect properties on array objects
* Fixed problem with chained timers with delay=0 (Ian Lewis)
* Use formatio in place of buster-format (Devin Weaver)
== 1.7.3 / 2013-06-20
* Removed use of array forEach, breaks in older browsers (Martin Hansen)
* sinon.deepEqual(new Date(0), new Date()) returns true (G.Serebryanskyi)
== 1.7.2 / 2013-05-08
* Sinon 1.7 has split calls out to a separate file. This caused some problems,
so 1.7.2 ships with spyCall as part of spy.js like it used to be.
== 1.7.1 / 2013-05-07
...every = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
function matchObject(expectation, actual) {
if (actual === null || actual === undefined) {
return false;
}
return Object.keys(expectation).every(function (key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
...extend = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
format = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Ensure sinon can run in a WebWorker
* Updated docs to reflect that calledOn accepts a matcher
* simplified test and added a note
* updated to require spy in its new cjs form
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
...functionName = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
functionToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
getConfig = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Breaking change: thisObj -> thisValue
Change brings consistency to the code-base, always use thisValue
* Add sinon.assert.pass callback for successful assertions
* Extract sandbox configuration from sinon.test
Refactored sinon.test to not do all the heavy lifting in creating sandbox
objects from sinon.config. Now sinon.sandbox.create accepts an optional
configuration that can be retrieved through sinon.getConfig({ ... }) - or, to
match previous behavior, through sinon.getConfig(sinon.config);
The default configuration now lives in sinon.defaultConfig rather than the
previous sinon.test.
This change enables external tools, such as test framework adapters, to easily
create configurable sandboxes without going through sinon.test
...getPropertyDescriptor = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
iterableToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
orderByFirstCall = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
restore = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...:(
n/a
function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...timesInWords = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
typeOf = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...walk = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
wrapMethod = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...calledInOrder = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
configureLogError = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
deepEqual = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Fixed deepEqual to detect properties on array objects
* Fixed problem with chained timers with delay=0 (Ian Lewis)
* Use formatio in place of buster-format (Devin Weaver)
== 1.7.3 / 2013-06-20
* Removed use of array forEach, breaks in older browsers (Martin Hansen)
* sinon.deepEqual(new Date(0), new Date()) returns true (G.Serebryanskyi)
== 1.7.2 / 2013-05-08
* Sinon 1.7 has split calls out to a separate file. This caused some problems,
so 1.7.2 ships with spyCall as part of spy.js like it used to be.
== 1.7.1 / 2013-05-07
...every = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
function matchObject(expectation, actual) {
if (actual === null || actual === undefined) {
return false;
}
return Object.keys(expectation).every(function (key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
...extend = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
format = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Ensure sinon can run in a WebWorker
* Updated docs to reflect that calledOn accepts a matcher
* simplified test and added a note
* updated to require spy in its new cjs form
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
...functionName = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
functionToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
getConfig = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Breaking change: thisObj -> thisValue
Change brings consistency to the code-base, always use thisValue
* Add sinon.assert.pass callback for successful assertions
* Extract sandbox configuration from sinon.test
Refactored sinon.test to not do all the heavy lifting in creating sandbox
objects from sinon.config. Now sinon.sandbox.create accepts an optional
configuration that can be retrieved through sinon.getConfig({ ... }) - or, to
match previous behavior, through sinon.getConfig(sinon.config);
The default configuration now lives in sinon.defaultConfig rather than the
previous sinon.test.
This change enables external tools, such as test framework adapters, to easily
create configurable sandboxes without going through sinon.test
...getPropertyDescriptor = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
iterableToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
orderByFirstCall = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
restore = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...:(
n/a
function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...timesInWords = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
typeOf = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...walk = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
wrapMethod = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
CustomEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
if (supportsProgress) {
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progressEventRaw));
}
},
uploadError: function uploadError(error) {
if (supportsCustomEvent) {
this.upload.dispatchEvent(new sinonEvent.CustomEvent("error", {detail
: error}));
}
},
overrideMimeType: function overrideMimeType(type) {
if (this.readyState >= FakeXMLHttpRequest.LOADING) {
throw new Error("INVALID_STATE_ERR");
}
...Event = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
this.readyStateChange(FakeXMLHttpRequest.OPENED);
},
readyStateChange: function readyStateChange(state) {
this.readyState = state;
var readyStateChangeEvent = new sinonEvent.Event("readystatechange", false,
false, this);
var event, progress;
if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
} catch (e) {
this.logError("Fake XHR onreadystatechange handler", e);
...function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}n/a
ProgressEvent = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
event = this.aborted ? "abort" : "error";
} else {
progress = {loaded: 100, total: 100};
event = "load";
}
if (supportsProgress) {
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress
, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.upload.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
}
this.dispatchEvent(new sinonEvent.ProgressEvent("progress", progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent(event, progress, this));
this.dispatchEvent(new sinonEvent.ProgressEvent("loadend", progress, this));
...addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...calledInOrder = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
configureLogError = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
deepEqual = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Fixed deepEqual to detect properties on array objects
* Fixed problem with chained timers with delay=0 (Ian Lewis)
* Use formatio in place of buster-format (Devin Weaver)
== 1.7.3 / 2013-06-20
* Removed use of array forEach, breaks in older browsers (Martin Hansen)
* sinon.deepEqual(new Date(0), new Date()) returns true (G.Serebryanskyi)
== 1.7.2 / 2013-05-08
* Sinon 1.7 has split calls out to a separate file. This caused some problems,
so 1.7.2 ships with spyCall as part of spy.js like it used to be.
== 1.7.1 / 2013-05-07
...every = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
}
function matchObject(expectation, actual) {
if (actual === null || actual === undefined) {
return false;
}
return Object.keys(expectation).every(function (key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
...extend = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
format = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Ensure sinon can run in a WebWorker
* Updated docs to reflect that calledOn accepts a matcher
* simplified test and added a note
* updated to require spy in its new cjs form
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
...functionName = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
functionToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
getConfig = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Breaking change: thisObj -> thisValue
Change brings consistency to the code-base, always use thisValue
* Add sinon.assert.pass callback for successful assertions
* Extract sandbox configuration from sinon.test
Refactored sinon.test to not do all the heavy lifting in creating sandbox
objects from sinon.config. Now sinon.sandbox.create accepts an optional
configuration that can be retrieved through sinon.getConfig({ ... }) - or, to
match previous behavior, through sinon.getConfig(sinon.config);
The default configuration now lives in sinon.defaultConfig rather than the
previous sinon.test.
This change enables external tools, such as test framework adapters, to easily
create configurable sandboxes without going through sinon.test
...getPropertyDescriptor = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
iterableToString = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function (actual) {
return deepEqual(expectation, actual);
};
}
if (!m.message) {
m.message = "match(" + valueToString(expectation) + ")";
}
return m;
}...
return result;
};
}
// create asynchronous versions of callsArg* and yields* methods
Object.keys(proto).forEach(function (method) {
// need to avoid creating anotherasync versions of the newly added async methods
if (method.match(/^(callsArg|yields)/) && !method.match(/Async/)) {
proto[method + "Async"] = createAsyncVersion(method);
}
});
function createBehavior(behaviorMethod) {
return function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
...function mock(object) {
if (!object) {
return mockExpectation.create("Anonymous mock");
}
return mock.create(object);
}n/a
orderByFirstCall = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
restore = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
* Fix #1026: stub watch method on object
* Fix invalid test for "does not walk the same property twice"
* Add test for issue #1026
* Fix 810 - Added documentation for sinon.restore()
* Add docs for new array matchers
* Array contains matcher fails when actual is not an array
* Array endsWith matcher fails when actual is not an array
* Array startsWith matcher fails when actual is not an array
* Array deepEquals matcher fails when actual is not an array
* Add .resolves and .rejects to stub (#1211)
* Accept routing DSLs on fake server
...function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...:(
n/a
function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...timesInWords = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
typeOf = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}...
return actual[property] !== undefined;
}, "has");
match.hasOwn = createPropertyMatcher(function (actual, property) {
return actual.hasOwnProperty(property);
}, "hasOwn");
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) {
return expectation[index] === element;
...useFakeTimers = function () {
var now;
var methods = Array.prototype.slice.call(arguments);
if (typeof methods[0] === "string") {
now = 0;
} else {
now = methods.shift();
}
var clock = llx.install(now || 0, methods);
clock.restore = clock.uninstall;
return clock;
}...
* Fix bug where expect.atLeast failed when minimum calls where received
* Make fake server safe to load on node.js
* Add support for no args on .withArgs and .withExactArgs (Tek Nynja)
* Avoid hasOwnProperty for host objects
== 1.3.2 / 2012-03-11
* Stronger Node inference in sandbox
* Fixed issue with sinon.useFakeTimers() and Rhino.js 1.7R3
* Formatting brush-up
* FIX Internet Explorer misreporting the type of Function objects
originating in an external window as "object" instead of "function".
* New methods stub.callsArgOn, stub.callsArgOnWith,
stub.yieldsOn, stub.yieldsToOn
* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
...function useFakeXMLHttpRequest() {
FakeXMLHttpRequest.restore = function restore(keepOnCreate) {
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = sinonXhr.GlobalActiveXObject;
}
delete FakeXMLHttpRequest.restore;
if (keepOnCreate !== true) {
delete FakeXMLHttpRequest.onCreate;
}
};
if (sinonXhr.supportsXHR) {
global.XMLHttpRequest = FakeXMLHttpRequest;
}
if (sinonXhr.supportsActiveX) {
global.ActiveXObject = function ActiveXObject(objId) {
if (objId === "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) {
return new FakeXMLHttpRequest();
}
return new sinonXhr.GlobalActiveXObject(objId);
};
}
return FakeXMLHttpRequest;
}...
}
this.server = proto.create();
return this.add(this.server);
},
useFakeXMLHttpRequest: function useFakeXMLHttpRequest() {
var xhr = fakeXhr.useFakeXMLHttpRequest();
return this.add(xhr);
},
inject: function (obj) {
sinonCollection.inject.call(this, obj);
if (this.clock) {
...walk = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
wrapMethod = function () {
exports.printWarning(msg);
return func.apply(this, arguments);
}n/a
function spy(object, property, types) {
var descriptor, methodDesc;
if (!property && typeof object === "function") {
return spy.create(object);
}
if (!object && !property) {
return spy.create(function () { });
}
if (!types) {
return wrapMethod(object, property, spy.create(object[property]));
}
descriptor = {};
methodDesc = getPropertyDescriptor(object, property);
types.forEach(function (type) {
descriptor[type] = spy.create(methodDesc[type]);
});
return wrapMethod(object, property, descriptor);
}...
* ./commonjs
* expose sinon.spy and sinon.spyCall
* converted spy to commonjs format
* moved sinon.format() to core
* fixed spy tests
* added missing test (pushes spy coverage to 100%)
* added spy getter/setter tests
* updated sinon.spy() to properly handle getters and setters
* Remove unnecessary error variable
* Prevent stubbed getter from being called during restore() - fixes #897
* Allowed GET requests to have request bodies
* Remove JSCS from devDependencies
* Add Gitter badge
* Allow yieldsOn, callsArgOn, callsArgOnWith, yieldsToOn to use any context
* Add bithound badge to README.md
...alwaysCalledOn = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysCalledWith = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysCalledWithExactly = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysCalledWithMatch = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysCalledWithNew = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysReturned = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
alwaysThrew = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
callArg = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
* Log some internal errors to sinon.log (defaults to noop). Set sinon.log
to your logging utility of choice for better feedback when.
* White-list fake XHRs: Allows some fake requests and some that fall through to
the backend server (Tim Ruffles)
* Decide Date.now support at fake-time. Makes it possible to load something that
polyfills Date.now after Sinon loaded and still have Date.now on fake Dates.
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
...callArgOn = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
callArgOnWith = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
callArgWith = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
* Log some internal errors to sinon.log (defaults to noop). Set sinon.log
to your logging utility of choice for better feedback when.
* White-list fake XHRs: Allows some fake requests and some that fall through to
the backend server (Tim Ruffles)
* Decide Date.now support at fake-time. Makes it possible to load something that
polyfills Date.now after Sinon loaded and still have Date.now on fake Dates.
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
...function calledAfter(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1];
}n/a
function calledBefore(spyFn) {
if (!this.called) {
return false;
}
if (!spyFn.called) {
return true;
}
return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1];
}...
module.exports = function calledInOrder(spies) {
if (arguments.length > 1) {
spies = arguments;
}
for (var i = 1, l = spies.length; i < l; i++) {
if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) {
return false;
}
}
return true;
};
...function calledImmediatelyAfter(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] === spyFn.callIds[spyFn.callCount - 1] + 1;
}n/a
function calledImmediatelyBefore(spyFn) {
if (!this.called || !spyFn.called) {
return false;
}
return this.callIds[this.callCount - 1] === spyFn.callIds[spyFn.callCount - 1] - 1;
}n/a
calledOn = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
calledWith = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
== 1.14.0 / 2015-03-13
* Stub & spy getters & setters (Simon Zack)
* Fix #702 async sinon.test using mocha interface (Mohayonao)
* Add respondImmediately to fake servers (Jonathan Freeman)
== 1.13.0 / 2015-03-04
* fix @depends-require mismatches (fixes AMD issues) (Ben Hockey)
* Fix spy.calledWith(undefined) to return false if it was called without args
* yieldsRight (Alexander Schmidt)
* stubs retain function arity (Charlie Rudolph)
* (AMD) use explicit define in built version
* spy().reset() returns this (Ali Shakiba)
* Add lengthComputable and download progress (Tamas Szebeni)
* Don't setContent-type when sending FormData (AJ Ortega)
* sinon.assert with spyCall (Alex Urbano)
...calledWithExactly = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
calledWithMatch = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
calledWithNew = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
if (matching) {
returnValue = matching.invoke(func, thisValue, args);
} else {
returnValue = (this.func || func).apply(thisValue, args);
}
var thisCall = this.getCall(this.callCount - 1);
if (thisCall.calledWithNew() && typeof returnValue !== "object"
;) {
returnValue = thisValue;
}
} catch (e) {
exception = e;
} finally {
delete this.invoking;
}
...function create(func, spyLength) {
var name;
if (typeof func !== "function") {
func = function () { };
} else {
name = functionName(func);
}
if (!spyLength) {
spyLength = func.length;
}
var proxy = createProxy(func, spyLength);
extend(proxy, spy);
delete proxy.create;
extend(proxy, func);
proxy.reset();
proxy.prototype = func.prototype;
proxy.displayName = name || "spy";
proxy.toString = functionToString;
proxy.instantiateFake = spy.create;
proxy.id = "spy#" + uuid++;
return proxy;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...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]);
}...
// describe multiple calls
if (l > 1) {
if (i > 0) {
message += "\n";
}
message += "Call " + (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 (sinonMatch.isMatcher(args[j])) {
message += colorSinonMatchText(args[j], calledArgs[j], calledArgMessage);
} else {
var expectedArgMessage = j < args.length ? sinonFormat(args[j]) : "";
...getCalls = function () {
var calls = [];
var i;
for (i = 0; i < this.callCount; i++) {
calls.push(this.getCall(i));
}
return calls;
}n/a
function invoke(func, thisValue, args) {
var matching = matchingFake(this.fakes, args);
var exception, returnValue;
incrementCallCount.call(this);
push.call(this.thisValues, thisValue);
push.call(this.args, args);
push.call(this.callIds, callId++);
// Make call properties available from within the spied function:
createCallProperties.call(this);
try {
this.invoking = true;
if (matching) {
returnValue = matching.invoke(func, thisValue, args);
} else {
returnValue = (this.func || func).apply(thisValue, args);
}
var thisCall = this.getCall(this.callCount - 1);
if (thisCall.calledWithNew() && typeof returnValue !== "object") {
returnValue = thisValue;
}
} catch (e) {
exception = e;
} finally {
delete this.invoking;
}
push.call(this.exceptions, exception);
push.call(this.returnValues, returnValue);
var err = new ErrorConstructor();
// 1. Please do not get stack at this point. It's 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.call(this.errorsWithCallStack, err);
// Make return value and exception available in the calls:
createCallProperties.call(this);
if (exception !== undefined) {
throw exception;
}
return returnValue;
}...
// 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.call(arguments
)); }; break;
case 2: p = function proxy(a, b) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 3: p = function proxy(a, b, c) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 4: p = function proxy(a, b, c, d) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 5: p = function proxy(a, b, c, d, e) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 6: p = function proxy(a, b, c, d, e, f) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 7: p = function proxy(a, b, c, d, e, f, g) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 8: p = function proxy(a, b, c, d, e, f, g, h) { return p.invoke(func, this, slice.call(arguments)); }; break;
...invokeCallback = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
matches = function (args, strict) {
var margs = this.matchingArguments;
if (margs.length <= args.length &&
deepEqual(margs, args.slice(0, margs.length))) {
return !strict || margs.length === args.length;
}
return undefined;
}...
function matchingFake(fakes, args, strict) {
if (!fakes) {
return undefined;
}
var matchingFakes = fakes.filter(function (fake) {
return fake.matches(args, strict);
});
return matchingFakes.pop();
}
function incrementCallCount() {
this.called = true;
...function named(name) {
this.displayName = name;
return this;
}n/a
neverCalledWith = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
method directly inside Sinon.
* Bug fix: Don't assume that req.requestBody is a string in the fake server.
* Added spy.printf(format) to print a nicely formatted message with details
about a spy.
* Garbage collection: removing fakes from collections when restoring the
original methods. Fix by Tristan Koch.
* Add spy.calledWithNew to check if a function was used as a constructor
* Add spy.notCalledWith(), spy.neverCalledWith() and
sinon.assert.neverCalledWith. By Max Antoni
* Publicly expose sinon.expectation.fail to allow tools to integrate with mock
expectations.
* Fake XMLHttpRequests now support a minimal portion of the events API, making
them work seamlessly with e.g. SproutCode (which uses
xhr.addEventListener("readystatechange"). Partially by Sven Fuchs.
...neverCalledWithMatch = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
printf = function (format) {
var spyInstance = this;
var args = slice.call(arguments, 1);
var formatter;
return (format || "").replace(/%(.)/g, function (match, specifyer) {
formatter = spyApi.formatters[specifyer];
if (typeof formatter === "function") {
return formatter.call(null, spyInstance, args);
} else if (!isNaN(parseInt(specifyer, 10))) {
return sinonFormat(args[specifyer - 1]);
}
return "%" + specifyer;
});
}...
* Matcher assertions: calledWithMatch, alwaysCalledWithMatch and
neverCalledWithMatch
* calledWithNew and alwaysCalledWithNew for assert (Maximilian Antoni)
* Easier stubbed fluent interfaces: stub.returnsThis() (Glen Mailer)
* allow yields() and family to be used along with returns()/throws() and
family (Glen Mailer)
* Async versions `callsArg*` and `yields*` for stubs (TEHEK)
* Format args when doing `spy.printf("%*")` (Domenic Denicola)
* Add notCalled property to spies
* Fix: spy.reset did not reset fakes created by spy.withArgs (Maximilian Antoni)
* Properly restore stubs when stubbing entire objects through the sandbox
(Konrad Holowinski)
* Restore global methods properly - delete properties that where not own
properties (Keith Cirkel)
* setTimeout and setInterval pass arguments (Rodion Vynnychenko)
...reset = function () {
if (this.invoking) {
var err = new Error("Cannot reset Sinon function while invoking it. " +
"Move the call to .reset 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) {
this.fakes.forEach(function (fake) {
fake.reset();
});
}
return this;
}...
* CJSify get-config tests (#1081)
* CJSify sinon.assert tests (#1078)
* Resolve test failure in node 0.10.x (#1073)
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
...returned = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
:(
n/a
threw = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
withArgs = function () {
var args = slice.call(arguments);
if (this.fakes) {
var match = matchingFake(this.fakes, args, true);
if (match) {
return match;
}
} else {
this.fakes = [];
}
var original = this;
var fake = this.instantiateFake();
fake.matchingArguments = args;
fake.parent = this;
push.call(this.fakes, fake);
fake.withArgs = function () {
return original.withArgs.apply(original, arguments);
};
original.args.forEach(function (arg, i) {
if (!fake.matches(arg)) {
return;
}
incrementCallCount.call(fake);
push.call(fake.thisValues, original.thisValues[i]);
push.call(fake.args, arg);
push.call(fake.returnValues, original.returnValues[i]);
push.call(fake.exceptions, original.exceptions[i]);
push.call(fake.callIds, original.callIds[i]);
});
createCallProperties.call(fake);
return fake;
}...
onThirdCall: function onThirdCall() {
return this.stub.onThirdCall();
},
withArgs: function withArgs(/* arguments */) {
throw new Error(
"Defining a stub by invoking \"stub.onCall(...).withArgs(...)\
x22; " +
"is not supported. Use \"stub.withArgs(...).onCall(...)\" " +
"to define sequential behavior for calls with certain arguments."
);
}
};
function createAsyncVersion(syncFnName) {
...yield = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
* Log some internal errors to sinon.log (defaults to noop). Set sinon.log
to your logging utility of choice for better feedback when.
* White-list fake XHRs: Allows some fake requests and some that fall through to
the backend server (Tim Ruffles)
* Decide Date.now support at fake-time. Makes it possible to load something that
polyfills Date.now after Sinon loaded and still have Date.now on fake Dates.
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
...yieldOn = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
yieldTo = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}...
* Log some internal errors to sinon.log (defaults to noop). Set sinon.log
to your logging utility of choice for better feedback when.
* White-list fake XHRs: Allows some fake requests and some that fall through to
the backend server (Tim Ruffles)
* Decide Date.now support at fake-time. Makes it possible to load something that
polyfills Date.now after Sinon loaded and still have Date.now on fake Dates.
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
...yieldToOn = function () {
if (!this.called) {
if (notCalled) {
return notCalled.apply(this, arguments);
}
return false;
}
var currentCall;
var matches = 0;
for (var i = 0, l = this.callCount; i < l; i += 1) {
currentCall = this.getCall(i);
if (currentCall[actual || method].apply(currentCall, arguments)) {
matches += 1;
if (matchAny) {
return true;
}
}
}
return matches === this.callCount;
}n/a
C = function (spyInstance) {
var calls = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
var stringifiedCall = " " + spyInstance.getCall(i).toString();
if (/\n/.test(calls[i - 1])) {
stringifiedCall = "\n" + stringifiedCall;
}
push.call(calls, stringifiedCall);
}
return calls.length > 0 ? "\n" + calls.join("\n") : "";
}n/a
D = function (spyInstance, args) {
var message = "";
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
// describe multiple calls
if (l > 1) {
if (i > 0) {
message += "\n";
}
message += "Call " + (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 (sinonMatch.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;
}n/a
c = function (spyInstance) {
return timesInWords(spyInstance.callCount);
}n/a
n = function (spyInstance) {
return spyInstance.toString();
}n/a
t = function (spyInstance) {
var objects = [];
for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
push.call(objects, sinonFormat(spyInstance.thisValues[i]));
}
return objects.join(", ");
}n/a
:(
n/a
toString = function () {
var callStr = this.proxy ? this.proxy.toString() + "(" : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = slice.call(this.args).map(function (arg) {
return sinonFormat(arg);
});
callStr = callStr + formattedArgs.join(", ") + ")";
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].replace(/^\s*(?:at\s+|@)?/, " at ");
}
return callStr;
}...
"' since no callback was passed.", args);
}
yieldFn.apply(thisValue, slice.call(arguments, 2));
},
toString: function () {
var callStr = this.proxy ? this.proxy.toString() + "(" : "";
var formattedArgs;
if (!this.args) {
return ":(";
}
formattedArgs = slice.call(this.args).map(function (arg) {
...function stub(object, property, descriptor) {
throwOnFalsyObject.apply(null, arguments);
var actualDescriptor = getPropertyDescriptor(object, property);
var isStubbingEntireObject = typeof property === "undefined" && typeof object === "object";
var isCreatingNewStub = !object && typeof property === "undefined";
var isStubbingDescriptor = object && property && Boolean(descriptor);
var isStubbingNonFuncProperty = typeof object === "object"
&& typeof property !== "undefined"
&& (typeof actualDescriptor === "undefined"
|| typeof actualDescriptor.value !== "function")
&& typeof descriptor === "undefined";
var isStubbingExistingMethod = !isStubbingDescriptor
&& typeof object === "object"
&& typeof actualDescriptor !== "undefined"
&& typeof actualDescriptor.value === "function";
var arity = isStubbingExistingMethod ? object[property].length : 0;
if (isStubbingEntireObject) {
return stubEntireObject(stub, object);
}
if (isStubbingDescriptor) {
return stubDescriptor.apply(null, arguments);
}
if (isCreatingNewStub) {
return stub.create();
}
var s = stub.create(arity);
s.rootObj = object;
s.propName = property;
s.restore = function restore() {
Object.defineProperty(object, property, actualDescriptor);
};
return isStubbingNonFuncProperty ? s : wrapMethod(object, property, s);
}...
// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
var wrapper;
deprecated.printWarning(
"sinon.stub(obj, 'meth', fn) is deprecated and will be removed from
x22; +
"the public API in a future version of sinon." +
"\n Use stub(obj, 'meth').callsFake(fn)." +
"\n Codemod available at https://github.com/hurrymaplelad/sinon-codemod"
);
if (!!descriptor && typeof descriptor !== "function" && typeof descriptor !== "object") {
throw new TypeError("Custom stub should be a property descriptor");
...addBehavior = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
exports.fakeServer = require("./sinon/util/fake_server");
exports.fakeServerWithClock = require("./sinon/util/fake_server_with_clock");
var behavior = require("./sinon/behavior");
exports.addBehavior = function (name, fn) {
behavior.addBehavior(exports.stub, name, fn);
};
...callThrough = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
* Merge pull request #1289 from mroderick/fix-invalid-release-version-in-docs
Fix invalid release number in v1.17.7.md front matter
* Merge pull request #1290 from sinonjs/common-eslint
Use common Sinon.JS eslint config
* Merge pull request #1288 from mroderick/improve-documentation
Improve documentation
* Merge pull request #1283 from lucasfcosta/docs-stub-callThrough
Add docs for stub.callThrough()
* Merge pull request #1285 from sinonjs/uncycle-server-deps
Uncycle server deps
* Merge pull request #1282 from sinonjs/mochify-3
Use mocaccino 2 and mochify 3
* Merge pull request #1281 from mroderick/add-missing-documentation
Add missing documentation
* Merge pull request #1277 from mroderick/remove-copyright-comments
...callsArg = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgOn = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgOnAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgOnWith = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgOnWithAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgWith = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsArgWithAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
callsFake = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
* Merge pull request #1203 from jdgreenberger/add-expectation-diff-logs
Add expectation diff logs
* Merge pull request #1208 from lucasfcosta/array-matchers
Array matchers
* Merge pull request #1209 from lucasfcosta/avoid-unnecessary-empty-stub-creation
Avoid unnecessary empty stub creation
* Merge pull request #1207 from hurrymaplelad/calls-fake
Replace `stub(o, 'm', fn)` with `stub(o, 'm').callsFake(fn)`
* Merge pull request #1162 from dottedmag/master
XHR spec conformance: abort() should not dispatch
readystatechange event in DONE state
* Merge pull request #1184 from mroderick/fail-on-empty-property-descriptor
Fail on empty property descriptor
* Merge pull request #1206 from fatso83/sinon-format-docs
Update format docs to refer to formatio
...function create(stubLength) {
var functionStub = function () {
return getCurrentBehavior(functionStub).invoke(this, arguments);
};
functionStub.id = "stub#" + uuid++;
var orig = functionStub;
functionStub = spy.create(functionStub, stubLength);
functionStub.func = orig;
extend(functionStub, stub);
functionStub.instantiateFake = stub.create;
functionStub.displayName = "stub";
functionStub.toString = functionToString;
functionStub.defaultBehavior = null;
functionStub.behaviors = [];
return functionStub;
}...
* Update changelog for pre.4
* Remove polyfill for Promise
* Remove old, unused, ci script for BusterJS
* Abort pre-commit script when no files are changed
* Check for required arguments
* Make SED in-place update switch work on BSD
* Upgrade text-encoding to the latest version
* Improve rendering of sandbox.create(config) example
* Remove sinon.test from sandbox documentation
* Use baseurl to render links correctly on github pages
* Specify same version of github-pages as github
* Remove release_id from front matter
* Update Gemfile.lock to use latest supported Jekyll
* Fix #614: Add missing documentation for sandbox methods
* Add missing documentation for stubs
...createBehavior = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
Object.keys(behavior).forEach(function (method) {
if (behavior.hasOwnProperty(method) &&
!proto.hasOwnProperty(method) &&
method !== "create" &&
method !== "withArgs" &&
method !== "invoke") {
proto[method] = behavior.createBehavior(method);
}
});
Object.keys(behaviors).forEach(function (method) {
if (behaviors.hasOwnProperty(method) && !proto.hasOwnProperty(method)) {
behavior.addBehavior(stub, method, behaviors[method]);
}
...createStubInstance = function (constructor) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
}
return stub(Object.create(constructor.prototype));
}n/a
get = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
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) {
...isPresent = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
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) {
...function onCall(index) {
if (!this.behaviors[index]) {
this.behaviors[index] = behavior.create(this);
}
return this.behaviors[index];
}...
} else if (this.callsThrough) {
return this.stub.wrappedMethod.apply(context, args);
}
return this.returnValue;
},
onCall: function onCall(index) {
return this.stub.onCall(index);
},
onFirstCall: function onFirstCall() {
return this.stub.onFirstCall();
},
onSecondCall: function onSecondCall() {
...function onFirstCall() {
return this.onCall(0);
}...
},
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() {
...function onSecondCall() {
return this.onCall(1);
}...
},
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 */) {
...function onThirdCall() {
return this.onCall(2);
}...
},
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."
...rejects = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...reset = function () {
this.resetHistory();
this.resetBehavior();
}...
* CJSify get-config tests (#1081)
* CJSify sinon.assert tests (#1078)
* Resolve test failure in node 0.10.x (#1073)
* Expose `sinon.assert` on sandbox instances. (#1076)
* Add resetBehavior and resetHistory to sandbox API (#1072)
* Fix incorrect inline function names
* Fix calledOnce on tests for #283. This closes #283.
* Add sandbox.reset() docs
* Add a line recommending how to pronounce.
* Improve tests based on PR feedback
* Allow xhr.respond(0) to simulate a network failure and call onerror
* Use event loaded instead of error event for code like 403, 500, etc.
* Fix invalid markdown in fake-timers.ms (#1054)
* Do not invoke getters in walk (#1059)
* ReactNative compatibility. Allow sinon fakeServer to run in React Native (#1052)
...resetBehavior = function () {
var fakes = this.fakes || [];
this.defaultBehavior = null;
this.behaviors = [];
delete this.returnValue;
delete this.returnArgAt;
delete this.fakeFn;
this.returnThis = false;
fakes.forEach(function (fake) {
fake.resetBehavior();
});
}...
delete this.returnValue;
delete this.returnArgAt;
delete this.fakeFn;
this.returnThis = false;
fakes.forEach(function (fake) {
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
...resetHistory = function () {
if (this.invoking) {
var err = new Error("Cannot reset Sinon function while invoking it. " +
"Move the call to .reset 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) {
this.fakes.forEach(function (fake) {
fake.reset();
});
}
return this;
}...
fake.resetBehavior();
});
},
resetHistory: spy.reset,
reset: function () {
this.resetHistory();
this.resetBehavior();
},
onCall: function onCall(index) {
if (!this.behaviors[index]) {
this.behaviors[index] = behavior.create(this);
}
...resolves = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
* Merge pull request #1253 from BenBrostoff/error-equality
Add error equality to deepEqual
* Merge pull request #1243 from sprzybylski/changelog-page
Update changelog page in postversion.sh
* Merge pull request #1239 from mroderick/refactor-stub-method
Refactor stub methods
* Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Add documentation for .rejects() and .resolves()
* Merge pull request #1241 from mroderick/cleanup-test-console
Stop polluting the test console with a "test" string
* Merge pull request #1238 from tarjei/patch-1
Document server.requests
* Merge pull request #1235 from jonnyreeves/feature/internalize
Internalise `typeOf` and `extends`
* Merge pull request #1233 from lucasfcosta/fix-deepEqual-for-matchers
...returns = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
returnsArg = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
* Mirror properties on replaced function properties
* New methods: spy.yield(), spy.yieldTo(), spy.callArg() and spy.callArgWith()
can be used to invoke callbacks passed to spies (while avoiding the mock-like
upfront yields() and friends). invokeCallback is available as an alias for
yield for people working with strict mode. (Maximilian Antoni)
* New properties: spy.firstCall, spy.secondCall, spy.thirdCall and spy.lastCall.
(Maximilian Antoni)
* New method: stub.returnsArg(), causes stub to return one of its arguments.
(Gavin Huang)
* Stubs now work for inherited methods. This was previously prohibited to avoid
stubbing not-yet-implemented methods. (Felix Geisendörfer)
* server.respond() can now accept the same arguments as server.respondWith() for
quick-and-dirty respondWith+respond. (Gavin Huang)
* Format objects with buster-format in the default bundle. Default to
util.inspect on node unless buster-format is available (not a hard dependency,
...returnsThis = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}...
falsy} as well as typeOf shortcuts for boolean, number, string, object,
function, array, regexp and date. The result of a call can be used with
spy.calledWith.
* spy.returned now works with matchers and compares objects deeply.
* Matcher assertions: calledWithMatch, alwaysCalledWithMatch and
neverCalledWithMatch
* calledWithNew and alwaysCalledWithNew for assert (Maximilian Antoni)
* Easier stubbed fluent interfaces: stub.returnsThis() (Glen Mailer)
* allow yields() and family to be used along with returns()/throws() and
family (Glen Mailer)
* Async versions `callsArg*` and `yields*` for stubs (TEHEK)
* Format args when doing `spy.printf("%*")` (Domenic Denicola)
* Add notCalled property to spies
* Fix: spy.reset did not reset fakes created by spy.withArgs (Maximilian Antoni)
* Properly restore stubs when stubbing entire objects through the sandbox
...set = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
throws = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
throwsException = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yields = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsOn = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsOnAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsRight = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsRightAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsTo = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsToAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsToOn = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
yieldsToOnAsync = function () {
this.defaultBehavior = this.defaultBehavior || proto.create(this);
this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments);
return this;
}n/a
function Date() { [native code] }n/a
clearImmediate = function (immediate) {
if (!immediate) return;
immediate._onImmediate = null;
immediateQueue.remove(immediate);
if (!immediateQueue.head) {
process._needImmediateCallback = false;
}
}n/a
clearInterval = function (timer) {
if (timer && timer._repeat) {
timer._repeat = null;
clearTimeout(timer);
}
}n/a
clearTimeout = function (timer) {
if (timer && (timer[kOnTimeout] || timer._onTimeout)) {
timer[kOnTimeout] = timer._onTimeout = null;
if (timer instanceof Timeout) {
timer.close(); // for after === 0
} else {
unenroll(timer);
}
}
}n/a
setImmediate = function () {
/*
* this function will do nothing
*/
return;
}n/a
setInterval = function () {
/*
* this function will do nothing
*/
return;
}n/a
setTimeout = function () {
/*
* this function will do nothing
*/
return;
}...
if (err.stack) {
config.logger(err.stack);
}
if (config.useImmediateExceptions) {
throwLoggedError();
} else {
config.setTimeout(throwLoggedError, 0);
}
};
}
module.exports = configure;
},{}],35:[function(require,module,exports){
...