Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sinon

Package Overview
Dependencies
Maintainers
4
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon - npm Package Compare versions

Comparing version 2.0.0-pre to 2.0.0-pre.2

lib/sinon/util/core/log_error.js

125

Changelog.txt
2.0.0 / 2015-12-02
2.0.0-pre.2 / 2016-07-07
==================
* CJSify sinon.call tests (#1079)
* CJSify sinon.calledInOrder tests (#1080)
* 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)
* 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)
* Fixed formatting of issue template
* Added note on using latest version
* Fix onerror event triggering for fake xhr requests (#1041)
* Add missing mocaccino and phantomic to package.json (#1029)
* Pull request and issue templates (#1012)
* Fix capturing of stack traces in Phantom.js.
* Allow sinon.calledInOrder to be called either with an array of spies or multiple spies as parameters. Add explicit test cases for sinon.calledInOrder
* Fix typos found by codespell
* Document faking of setImmediate and clearImmediate
* Add feature detection guard for tests containing es6 Symbols
* Add support for es6 Symbol to wrapMethod method
* Convert values to strings with toString instead of String()
* Add typeOf matcher for symbol type
* Make expectetation fail as expected when called with wrong Symbol
* Make mock report expected TypeError when expecting number and given symbol
* Add support for es6 Symbol to match.has method
* Make error message when failing to stub method support es6 symbol
* Make yieldToOn fail as expected when yielding an es6 Symbol
* Add support for es6 Symbol to match.same method
* Make yieldTo fail as expected when yielding an es6 Symbol
* Add support for es6 Symbol to match method
* Work around SauceLabs security limitations
* Declare test specific eslint configs in test/.eslintrc
* Add test-coverage script
* Add eslint-plugin-mocha
* Remove browserify-shim
* Setup saucelabs tests and adjust travis config
* Feature detect __proto__ to exclude a timer test in IE 10
* Convert webworker test to mocha
* Remove buster
* Replace npm test script with mocha / mochify invocations
* Fix async fake-xml-http-request tests
* Convert issues tests to mocha
* Convert util tests to mocha
* Convert core tests to mocha
* Convert stub tests to mocha
* Convert typeof tests to mocha
* Convert spy tests to mocha
* Convert sandbox tests to mocha
* Convert mock tests to mocha
* Convert hello world test to mocha
* Convert extend tests to mocha
* Convert collection tests to mocha
* Convert call tests to mocha
* Convert assert tests to mocha
* Convert matcher tests to mocha
* Update docs/TODO.md to reflect plan to Jekyll
* CJSify Spy and Stub Tests.
* CJSify Core Util Tests.
* Migrate Packaged Tests to use a Browserified Build.
* fix non enumerable methods stub restore
* 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`
* Extract `deep-equal` tests from `sinon-test`.
* Extract `wrap-method` tests from `sinon-test`.
* Extract `extend` tests from `sinon-test` to `extend-test`
* Move 'lib/util/core' tests into 'test/util/core'
* Remove the use of `sinon.format` from the codebase
* Require sinon.deepEqual in a more modular way
* Fix 648: test for this.proxy before trying toString on it
* use the correct sinon.deepEqual to test sinon matcher
* add stub test to ensure sinon matcher is recognized within stub.withArgs
* update repo link
* Remove unused dependency util
* Update samsam
* Update lolex
* Update browserify
* Update dependency pre-commit
* Update buster-istanbul to 0.1.15
* ignore webstorm configs
* fix async issues and increase buster timeout
* test on node 5
* Fixes typo error in docs
* fix typo in lib/sinon.js
* Fixes typo error in docs
* Adding comment to warn against using eval
* fix linting
* Get rid of eval in sinon spy
* Update README URLs based on HTTP redirects
2.0.0-pre / 2015-12-02
==================
* 2.0.0 pre-release
* Extract `sandbox` into a CommonJS module.
* Clarify documentation on creating stubs and spies
* Extract `util/fake_server_with_clock` into a CommonJS module

@@ -88,4 +207,2 @@ * Extract `util/fake_server` into a CommonJS module.

* Run tests in node 4.1.x also
* First effort towards moving to CommonJS
* Update Changelog.txt
* stub.reset also resets behavior

@@ -389,3 +506,3 @@

* Implemented
* Fixing `clearTimeout` to not throw when called for nonexistant IDs.
* Fixing `clearTimeout` to not throw when called for nonexistent IDs.
* Spys that are created using 'withArgs' now get initialized with previous

@@ -392,0 +509,0 @@ calls to the original spy.

28

CONTRIBUTING.md

@@ -6,3 +6,3 @@ # Contributing to Sinon.JS

* Help [improve the documentation](https://github.com/sinonjs/sinon-docs) published at [the Sinon.JS website](http://sinonjs.org)
* Help someone understand and use Sinon.JS on the [the mailing list](http://groups.google.com/group/sinonjs)
* Help someone understand and use Sinon.JS on [the mailing list](http://groups.google.com/group/sinonjs)
* Report an issue, please read instructions below

@@ -14,3 +14,3 @@ * Help with triaging the [issues](http://github.com/cjohansen/Sinon.JS/issues). The clearer they are, the more likely they are to be fixed soon.

To save everyone time and make it much more likely for your issue to be understood, worked on and resolved quickly, it would help if you're mindful of [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) when pressing the "Submit new issue" button.
To save everyone time and make it much more likely for your issue to be understood, worked on and resolved quickly, it would help if you're mindful of [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html) when pressing the "Submit new issue" button.

@@ -27,26 +27,4 @@ As a minimum, please report the following:

### Bug report template
See [our issue template](https://github.com/sinonjs/sinon/blob/master/.github/) for all details.
Here's a template for a bug report
> Sinon version :
> Environment :
> Example URL :
>
> ##### Bug description
Here's an example use of the template
> Sinon version : 1.10.3
> Environment : OSX Chrome 37.0.2062.94
> Example URL : http://jsbin.com/iyebiWI/8/edit
>
> ##### Bug description
>
> If `respondWith` called with a URL including query parameter and a function , it doesn't work.
> This error reported in console.
> ```
> `TypeError: requestUrl.match(...) is null`
> ```
## Contributing to the code base

@@ -53,0 +31,0 @@

@@ -23,2 +23,3 @@ /**

exports.mock = require("./sinon/mock");
exports.sandbox = require("./sinon/sandbox");
exports.expectation = require("./sinon/mock-expectation");

@@ -28,5 +29,2 @@ exports.createStubInstance = require("./sinon/stub").createStubInstance;

exports.log = function () {};
exports.logError = require("./sinon/log_error");
var event = require("./sinon/util/event");

@@ -58,3 +56,3 @@ exports.Event = event.Event;

* allow deepEqual to check equality of matchers through
* dependency injectection. Otherwise we get a circular
* dependency injection. Otherwise we get a circular
* dependency

@@ -64,5 +62,1 @@ */

// Modifying exports of another modules is not the right
// way to handle exports in CommonJS but this is a minimal
// change to how sinon was built before.
require("./sinon/test_case");

@@ -14,2 +14,3 @@ /**

var functionName = require("./util/core/function-name");
var valueToString = require("./util/core/value-to-string");

@@ -87,3 +88,3 @@ var slice = Array.prototype.slice;

msg = functionName(behavior.stub) +
" expected to yield to '" + behavior.callArgProp +
" expected to yield to '" + valueToString(behavior.callArgProp) +
"', but no object with such a property was passed.";

@@ -90,0 +91,0 @@ } else {

@@ -13,3 +13,2 @@ /**

var sinon = require("./util/core");
var sinonMatch = require("./match");

@@ -19,2 +18,4 @@ var deepEqual = require("./util/core/deep-equal").use(sinonMatch);

var createInstance = require("./util/core/create");
var sinonFormat = require("./util/core/format");
var valueToString = require("./util/core/value-to-string");
var slice = Array.prototype.slice;

@@ -148,3 +149,3 @@

}
throwYieldError(this.proxy, " cannot yield to '" + prop +
throwYieldError(this.proxy, " cannot yield to '" + valueToString(prop) +
"' since no callback was passed.", args);

@@ -159,7 +160,11 @@ },

toString: function () {
var callStr = this.proxy.toString() + "(";
var callStr = this.proxy ? this.proxy.toString() + "(" : "";
var args = [];
if (!this.args) {
return ":(";
}
for (var i = 0, l = this.args.length; i < l; ++i) {
args.push(sinon.format(this.args[i]));
args.push(sinonFormat(this.args[i]));
}

@@ -170,3 +175,3 @@

if (typeof this.returnValue !== "undefined") {
callStr += " => " + sinon.format(this.returnValue);
callStr += " => " + sinonFormat(this.returnValue);
}

@@ -173,0 +178,0 @@

@@ -13,2 +13,5 @@ /**

var sinonSpy = require("./spy");
var walk = require("./util/core/walk");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var valueToString = require("./util/core/value-to-string");

@@ -45,3 +48,3 @@ var push = [].push;

var collection = {
verify: function resolve() {
verify: function verify() {
each(this, "verify");

@@ -55,6 +58,14 @@ },

reset: function restore() {
reset: function reset() {
each(this, "reset");
},
resetBehavior: function resetBehavior() {
each(this, "resetBehavior");
},
resetHistory: function resetHistory() {
each(this, "resetHistory");
},
verifyAndRestore: function verifyAndRestore() {

@@ -89,3 +100,3 @@ var exception;

var type = object === null ? "null" : "undefined";
throw new Error("Trying to stub property '" + property + "' of " + type);
throw new Error("Trying to stub property '" + valueToString(property) + "' of " + type);
}

@@ -97,3 +108,3 @@

if (!hasOwnProperty.call(object, property)) {
throw new TypeError("Cannot stub non-existent own property " + property);
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
}

@@ -111,9 +122,12 @@

if (!property && !!object && typeof object === "object") {
var col = this;
var stubbedObj = sinon.stub.apply(sinon, arguments);
for (var prop in stubbedObj) {
if (typeof stubbedObj[prop] === "function") {
this.add(stubbedObj[prop]);
walk(stubbedObj, function (prop, propOwner) {
if (
typeof getPropertyDescriptor(propOwner, prop).value === "function"
) {
col.add(stubbedObj[prop]);
}
}
});

@@ -120,0 +134,0 @@ return stubbedObj;

@@ -15,2 +15,3 @@ /**

var typeOf = require("./typeOf");
var valueToString = require("./util/core/value-to-string");

@@ -84,3 +85,3 @@ function assertType(value, type, name) {

if (expectation.hasOwnProperty(key)) {
array.push(key + ": " + expectation[key]);
array.push(key + ": " + valueToString(expectation[key]));
}

@@ -119,3 +120,3 @@ }

if (!m.message) {
m.message = "match(" + expectation + ")";
m.message = "match(" + valueToString(expectation) + ")";
}

@@ -177,3 +178,3 @@

return expectation === actual;
}, "same(" + expectation + ")");
}, "same(" + valueToString(expectation) + ")");
};

@@ -201,3 +202,3 @@

if (!onlyProperty) {
message += ", " + value;
message += ", " + valueToString(value);
}

@@ -234,3 +235,4 @@ message += ")";

match.date = match.typeOf("date");
match.symbol = match.typeOf("symbol");
module.exports = match;

@@ -20,2 +20,3 @@ /**

var format = require("./util/core/format");
var valueToString = require("./util/core/value-to-string");

@@ -93,3 +94,3 @@ var slice = Array.prototype.slice;

if (typeof num !== "number") {
throw new TypeError("'" + num + "' is not number");
throw new TypeError("'" + valueToString(num) + "' is not number");
}

@@ -109,3 +110,3 @@

if (typeof num !== "number") {
throw new TypeError("'" + num + "' is not number");
throw new TypeError("'" + valueToString(num) + "' is not number");
}

@@ -141,3 +142,3 @@

if (typeof num !== "number") {
throw new TypeError("'" + num + "' is not a number");
throw new TypeError("'" + valueToString(num) + "' is not a number");
}

@@ -160,4 +161,4 @@

if ("expectedThis" in this && this.expectedThis !== thisValue) {
mockExpectation.fail(this.method + " called with " + thisValue + " as thisValue, expected " +
this.expectedThis);
mockExpectation.fail(this.method + " called with " + valueToString(thisValue) +
" as thisValue, expected " + valueToString(this.expectedThis));
}

@@ -164,0 +165,0 @@

@@ -12,10 +12,14 @@ /**

require("./extend");
require("./collection");
require("./util/fake_server_with_clock");
require("./util/fake_timers");
var sinon = require("./util/core");
var extend = require("./extend");
var createInstance = require("./util/core/create");
var sinonCollection = require("./collection");
var sinonMatch = require("./match");
var sinonAssert = require("./assert");
var push = [].push;
var sinonSandbox = createInstance(sinonCollection);
function exposeValue(sandbox, config, key, value) {

@@ -35,3 +39,3 @@ if (!value) {

function prepareSandboxFromConfig(config) {
var sandbox = sinon.create(sinon.sandbox);
var sandbox = createInstance(sinonSandbox);

@@ -57,3 +61,3 @@ if (config.useFakeServer) {

sinon.sandbox = sinon.extend(sinon.create(sinon.collection), {
extend(sinonSandbox, {
useFakeTimers: function useFakeTimers() {

@@ -65,3 +69,3 @@ this.clock = sinon.useFakeTimers.apply(sinon, arguments);

serverPrototype: sinon.fakeServer,
serverPrototype: sinon.fakeServerWithClock,

@@ -80,3 +84,3 @@ useFakeServer: function useFakeServer() {

inject: function (obj) {
sinon.collection.inject.call(this, obj);
sinonCollection.inject.call(this, obj);

@@ -92,3 +96,3 @@ if (this.clock) {

obj.match = sinon.match;
obj.match = sinonMatch;

@@ -99,3 +103,3 @@ return obj;

restore: function () {
sinon.collection.restore.apply(this, arguments);
sinonCollection.restore.apply(this, arguments);
this.restoreContext();

@@ -115,3 +119,3 @@ },

if (!config) {
return sinon.create(sinon.sandbox);
return createInstance(sinonSandbox);
}

@@ -140,5 +144,9 @@

match: sinon.match
match: sinonMatch,
assert: sinonAssert
});
sinon.sandbox.useFakeXMLHttpRequest = sinon.sandbox.useFakeServer;
sinonSandbox.useFakeXMLHttpRequest = sinonSandbox.useFakeServer;
module.exports = sinonSandbox;

@@ -12,10 +12,12 @@ /**

var extend = require("./extend");
var deepEqual = require("./util/core/deep-equal");
var functionName = require("./util/core/function-name");
var functionToString = require("./util/core/function-to-string");
var getPropertyDescriptor = require("./util/core/get-property-descriptor");
var sinon = require("./util/core");
var sinonMatch = require("./match");
var deepEqual = require("./util/core/deep-equal").use(sinonMatch);
var spyCall = require("./call");
var timesInWords = require("./util/core/times-in-words");
var wrapMethod = require("./util/core/wrap-method");
var sinonFormat = require("./util/core/format");
var valueToString = require("./util/core/value-to-string");

@@ -78,3 +80,2 @@ var push = Array.prototype.push;

var vars = "a,b,c,d,e,f,g,h,i,j,k,l";
function createProxy(func, proxyLength) {

@@ -84,4 +85,21 @@ // Retain the function length:

if (proxyLength) {
eval("p = (function proxy(" + vars.substring(0, proxyLength * 2 - 1) + // eslint-disable-line no-eval
") { return p.invoke(func, this, slice.call(arguments)); });");
// 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;
case 9: p = function proxy(a, b, c, d, e, f, g, h, i) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 10: p = function proxy(a, b, c, d, e, f, g, h, i, j) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 11: p = function proxy(a, b, c, d, e, f, g, h, i, j, k) { return p.invoke(func, this, slice.call(arguments)); }; break;
case 12: p = function proxy(a, b, c, d, e, f, g, h, i, j, k, l) { return p.invoke(func, this, slice.call(arguments)); }; break;
default: p = function proxy() { return p.invoke(func, this, slice.call(arguments)); }; break;
/*eslint-enable*/
}
} else {

@@ -195,3 +213,12 @@ p = function proxy() {

push.call(this.returnValues, returnValue);
push.call(this.stacks, new Error().stack);
var err = new Error();
var stack = err.stack;
if (!stack) {
// 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.stacks, err.stack);

@@ -312,3 +339,3 @@ // Make return value and exception available in the calls:

} else if (!isNaN(parseInt(specifyer, 10))) {
return sinon.format(args[specifyer - 1]);
return sinonFormat(args[specifyer - 1]);
}

@@ -386,7 +413,7 @@

delegateToCalls("yieldTo", false, "yieldTo", function (property) {
throw new Error(this.toString() + " cannot yield to '" + property +
throw new Error(this.toString() + " cannot yield to '" + valueToString(property) +
"' since it was not yet invoked.");
});
delegateToCalls("yieldToOn", false, "yieldToOn", function (property) {
throw new Error(this.toString() + " cannot yield to '" + property +
throw new Error(this.toString() + " cannot yield to '" + valueToString(property) +
"' since it was not yet invoked.");

@@ -422,3 +449,3 @@ });

for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
push.call(objects, sinon.format(spyInstance.thisValues[i]));
push.call(objects, sinonFormat(spyInstance.thisValues[i]));
}

@@ -433,3 +460,3 @@

for (var i = 0, l = args.length; i < l; ++i) {
push.call(formatted, sinon.format(args[i]));
push.call(formatted, sinonFormat(args[i]));
}

@@ -436,0 +463,0 @@

@@ -19,2 +19,3 @@ /**

var functionToString = require("./util/core/function-to-string");
var valueToString = require("./util/core/value-to-string");
var wrapMethod = require("./util/core/wrap-method");

@@ -29,3 +30,3 @@

var type = object === null ? "null" : "undefined";
throw new Error("Trying to stub property '" + property + "' of " + type);
throw new Error("Trying to stub property '" + valueToString(property) + "' of " + type);
}

@@ -60,3 +61,3 @@

if (typeof property === "undefined" && typeof object === "object") {
walk(object || {}, function (value, prop, propOwner) {
walk(object || {}, function (prop, propOwner) {
// we don't want to stub things like toString(), valueOf(), etc. so we only stub if the object

@@ -63,0 +64,0 @@ // is not Object.prototype

"use strict";
module.exports = function calledInOrder(spies) {
if (arguments.length > 1) {
spies = arguments;
}
for (var i = 1, l = spies.length; i < l; i++) {

@@ -5,0 +9,0 @@ if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) {

@@ -40,1 +40,3 @@ /**

exports.restore = require("./restore");
exports.configureLogError = require("./log_error");
"use strict";
var walk = require("./walk");
function isRestorable(obj) {

@@ -9,7 +11,7 @@ return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon;

if (object !== null && typeof object === "object") {
for (var prop in object) {
walk(object, function (prop) {
if (isRestorable(object[prop])) {
object[prop].restore();
}
}
});
} else if (isRestorable(object)) {

@@ -16,0 +18,0 @@ object.restore();

@@ -23,3 +23,3 @@ "use strict";

originalObj : obj;
iterator.call(context, target[k], k, target);
iterator.call(context, k, target);
}

@@ -26,0 +26,0 @@ });

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

var objectKeys = require("./object-keys");
var valueToString = require("./value-to-string");

@@ -38,8 +39,8 @@ var hasOwn = Object.prototype.hasOwnProperty;

error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " +
property + " as function");
valueToString(property) + " as function");
} else if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
error = new TypeError("Attempted to wrap " + property + " which is already wrapped");
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already wrapped");
} else if (wrappedMethod.calledBefore) {
var verb = wrappedMethod.returns ? "stubbed" : "spied on";
error = new TypeError("Attempted to wrap " + property + " which is already " + verb);
error = new TypeError("Attempted to wrap " + valueToString(property) + " which is already " + verb);
}

@@ -46,0 +47,0 @@

@@ -5,3 +5,3 @@ /**

* 1.3.x, which does not use xhr object's onreadystatehandler at all - instead,
* it polls the object for completion with setInterval. Dispite the direct
* it polls the object for completion with setInterval. Despite the direct
* motivation, there is nothing jQuery-specific in this file, so it can be used

@@ -8,0 +8,0 @@ * in any environment where the ajax implementation depends on setInterval or

@@ -18,2 +18,3 @@ /**

var format = require("./core/format");
var configureLogError = require("./core/log_error");

@@ -35,3 +36,3 @@ function responseArray(handler) {

var wloc = typeof window !== "undefined" ? window.location : {};
var wloc = typeof window !== "undefined" ? window.location : { "host": "localhost", "protocol": "http"};
var rCurrLoc = new RegExp("^" + wloc.protocol + "//" + wloc.host);

@@ -85,2 +86,3 @@

},
configure: function (config) {

@@ -91,3 +93,4 @@ var whitelist = {

"respondImmediately": true,
"fakeHTTPMethods": true
"fakeHTTPMethods": true,
"logger": true
};

@@ -102,3 +105,5 @@ var setting;

}
this.logError = configureLogError(config);
},
addRequest: function addRequest(xhrObj) {

@@ -145,2 +150,8 @@ var server = this;

logger: function () {
// no-op; override via configure()
},
logError: configureLogError({}),
log: function log(response, request) {

@@ -152,3 +163,5 @@ var str;

sinon.log(str);
if (typeof this.logger === "function") {
this.logger(str);
}
},

@@ -220,3 +233,3 @@

} catch (e) {
sinon.logError("Fake server request processing", e);
this.logError("Fake server request processing", e);
}

@@ -223,0 +236,0 @@ },

@@ -9,3 +9,3 @@ /**

var extend = require("../extend");
var logError = require("../log_error");
var configureLogError = require("./core/log_error");

@@ -17,3 +17,3 @@ var xdr = { XDomainRequest: global.XDomainRequest };

function FakeXDomainRequest() {
function FakeXDomainRequest(config) {
this.readyState = FakeXDomainRequest.UNSENT;

@@ -24,2 +24,3 @@ this.requestBody = null;

this.timeout = null;
this.logError = configureLogError(config);

@@ -93,2 +94,4 @@ if (typeof FakeXDomainRequest.onCreate === "function") {

break;
default:
throw new Error("Unhandled state");
}

@@ -102,3 +105,3 @@

} catch (e) {
logError("Fake XHR " + eventName + " handler", e);
this.logError("Fake XHR " + eventName + " handler", e);
}

@@ -105,0 +108,0 @@ }

@@ -13,3 +13,3 @@ /**

var sinon = require("./core");
var configureLogError = require("./core/log_error");
var sinonEvent = require("./event");

@@ -38,3 +38,10 @@ var extend = require("../extend");

var supportsArrayBuffer = typeof ArrayBuffer !== "undefined";
var supportsBlob = typeof Blob === "function";
var supportsBlob = (function () {
try {
return !!new Blob();
} catch (e) {
return false;
}
})();
var isReactNative = global.navigator && global.navigator.product === "ReactNative";
var sinonXhr = { XMLHttpRequest: global.XMLHttpRequest };

@@ -46,3 +53,4 @@ sinonXhr.GlobalXMLHttpRequest = global.XMLHttpRequest;

sinonXhr.workingXHR = getWorkingXHR(global);
sinonXhr.supportsCORS = sinonXhr.supportsXHR && "withCredentials" in (new sinonXhr.GlobalXMLHttpRequest());
sinonXhr.supportsCORS = isReactNative ||
(sinonXhr.supportsXHR && "withCredentials" in (new sinonXhr.GlobalXMLHttpRequest()));

@@ -110,3 +118,3 @@ var unsafeHeaders = {

// set responseType before calling open, send or respond;
function FakeXMLHttpRequest() {
function FakeXMLHttpRequest(config) {
this.readyState = FakeXMLHttpRequest.UNSENT;

@@ -120,2 +128,3 @@ this.requestHeaders = {};

this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsCORS) {

@@ -126,3 +135,3 @@ this.withCredentials = false;

var xhr = this;
var events = ["loadstart", "load", "abort", "loadend"];
var events = ["loadstart", "load", "abort", "error", "loadend"];

@@ -198,2 +207,3 @@ function addEventListener(eventName) {

case 5: return obj[method](args[0], args[1], args[2], args[3], args[4]);
default: throw new Error("Unhandled case");
}

@@ -444,3 +454,3 @@ };

} catch (e) {
sinon.logError("Fake XHR onreadystatechange handler", e);
this.logError("Fake XHR onreadystatechange handler", e);
}

@@ -450,7 +460,6 @@ }

if (this.readyState === FakeXMLHttpRequest.DONE) {
if (this.status < 200 || this.status > 299) {
if (this.aborted || this.status === 0) {
progress = {loaded: 0, total: 0};
event = this.aborted ? "abort" : "error";
}
else {
} else {
progress = {loaded: 100, total: 100};

@@ -549,2 +558,11 @@ event = "load";

error: function () {
clearResponse(this);
this.errorFlag = true;
this.requestHeaders = {};
this.responseHeaders = {};
this.readyStateChange(FakeXMLHttpRequest.DONE);
},
getResponseHeader: function getResponseHeader(header) {

@@ -551,0 +569,0 @@ if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) {

{
"name": "sinon",
"description": "JavaScript test spies, stubs and mocks.",
"version": "2.0.0-pre",
"version": "2.0.0-pre.2",
"homepage": "http://sinonjs.org/",

@@ -9,7 +9,7 @@ "author": "Christian Johansen",

"type": "git",
"url": "http://github.com/cjohansen/Sinon.JS.git"
"url": "http://github.com/sinonjs/sinon.git"
},
"bugs": {
"mail": "christian@cjohansen.no",
"url": "http://github.com/cjohansen/Sinon.JS/issues"
"url": "http://github.com/sinonjs/sinon/issues"
},

@@ -19,3 +19,8 @@ "license": "BSD-3-Clause",

"ci-test": "npm run lint && ./scripts/ci-test.sh",
"test": "./scripts/ci-test.sh",
"test-node": "mocha --recursive -R dot test/",
"test-headless": "mochify --recursive -R dot --grep WebWorker --invert test/",
"test-coverage": "mochify --recursive -R dot --grep WebWorker --invert --plugin [ mochify-istanbul --report text ] test/",
"test-cloud": "npm run test-headless -- --wd",
"test-webworker": "browserify --no-commondir --full-paths -p [ mocaccino -R spec --color ] test/webworker/webworker-support-assessment.js | phantomic --web-security false",
"test": "npm run test-node && npm run test-headless && npm run test-webworker",
"lint": "eslint .",

@@ -30,15 +35,18 @@ "prepublish": "./build",

"formatio": "1.1.1",
"util": ">=0.10.3 <1",
"lolex": "1.3.2",
"samsam": "1.1.2",
"lolex": "^1.4.0",
"samsam": "^1.1.3",
"text-encoding": "0.5.2"
},
"devDependencies": {
"browserify": "^11.1.0",
"buster": "0.7.18",
"buster-core": "^0.6.4",
"buster-istanbul": "0.1.13",
"browserify": "^13.0.0",
"eslint": "^1.7.1",
"eslint-config-defaults": "^2.1.0",
"pre-commit": "1.0.10"
"eslint-plugin-mocha": "^1.1.0",
"mocaccino": "^1.8.2",
"mocha": "^2.4.5",
"mochify": "^2.17.0",
"mochify-istanbul": "^2.4.1",
"phantomic": "^1.4.0",
"pre-commit": "^1.1.2",
"referee": "^1.2.0"
},

@@ -45,0 +53,0 @@ "files": [

/**
* Sinon.JS 2.0.0-pre, 2015/12/02
* Sinon.JS 2.0.0-pre, 2016/07/07
*

@@ -4,0 +4,0 @@ * @author Christian Johansen (christian@cjohansen.no)

/**
* Sinon.JS 2.0.0-pre, 2015/12/02
* Sinon.JS 2.0.0-pre.2, 2016/07/07
*

@@ -4,0 +4,0 @@ * @author Christian Johansen (christian@cjohansen.no)

@@ -7,7 +7,7 @@ # Sinon.JS

Standalone and test framework agnostic JavaScript test spies, stubs and mocks.
Standalone and test framework agnostic JavaScript test spies, stubs and mocks (pronounced "sigh-non").
## Installation
via [npm (node package manager)](http://github.com/isaacs/npm)
via [npm (node package manager)](https://github.com/npm/npm)

@@ -14,0 +14,0 @@ $ npm install sinon

Sorry, the diff of this file is not supported yet

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc