Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,9 @@ | ||
2.2.0 / 2017-05-02 | ||
================== | ||
* Added `usingPromise` method to stub and sandbox. | ||
* Added support for React Native window location format Fixes sinonjs/sinon#1362 | ||
* Fix error on call.toString() where stack has fewer than 4 lines. | ||
2.1.0 / 2017-03-20 | ||
@@ -2,0 +10,0 @@ ================== |
@@ -132,5 +132,5 @@ "use strict"; | ||
} else if (this.resolve) { | ||
return Promise.resolve(this.returnValue); | ||
return (this.promiseLibrary || Promise).resolve(this.returnValue); | ||
} else if (this.reject) { | ||
return Promise.reject(this.returnValue); | ||
return (this.promiseLibrary || Promise).reject(this.returnValue); | ||
} else if (this.callsThrough) { | ||
@@ -137,0 +137,0 @@ return this.stub.wrappedMethod.apply(context, args); |
@@ -179,3 +179,3 @@ "use strict"; | ||
// Omit the error message and the two top stack frames in sinon itself: | ||
callStr += this.stack.split("\n")[3].replace(/^\s*(?:at\s+|@)?/, " at "); | ||
callStr += ( this.stack.split("\n")[3] || "unknown" ).replace(/^\s*(?:at\s+|@)?/, " at "); | ||
} | ||
@@ -182,0 +182,0 @@ |
@@ -74,2 +74,7 @@ "use strict"; | ||
addUsingPromise: function (fake) { | ||
fake.usingPromise(this.promiseLibrary); | ||
return fake; | ||
}, | ||
spy: function spy() { | ||
@@ -89,5 +94,12 @@ return this.add(sinonSpy.apply(sinonSpy, arguments)); | ||
if (isStubbingEntireObject) { | ||
collectOwnMethods(stubbed).forEach(this.add.bind(this)); | ||
var ownMethods = collectOwnMethods(stubbed); | ||
ownMethods.forEach(this.add.bind(this)); | ||
if (this.promiseLibrary) { | ||
ownMethods.forEach(this.addUsingPromise.bind(this)); | ||
} | ||
} else { | ||
this.add(stubbed); | ||
if (this.promiseLibrary) { | ||
stubbed.usingPromise(this.promiseLibrary); | ||
} | ||
} | ||
@@ -94,0 +106,0 @@ |
@@ -71,2 +71,6 @@ "use strict"; | ||
usingPromise: function usingPromise(fake, promiseLibrary) { | ||
fake.promiseLibrary = promiseLibrary; | ||
}, | ||
yields: function (fake) { | ||
@@ -73,0 +77,0 @@ fake.callArgAt = useLeftMostCallback; |
@@ -93,2 +93,9 @@ "use strict"; | ||
usingPromise: function (promiseLibrary) { | ||
this.promiseLibrary = promiseLibrary; | ||
return this; | ||
}, | ||
restore: function () { | ||
@@ -95,0 +102,0 @@ if (arguments.length) { |
@@ -24,3 +24,27 @@ "use strict"; | ||
var wloc = typeof window !== "undefined" ? window.location : { "host": "localhost", "protocol": "http"}; | ||
function getDefaultWindowLocation() { | ||
return { "host": "localhost", "protocol": "http" }; | ||
} | ||
function getWindowLocation() { | ||
if (typeof window === "undefined") { | ||
// Fallback | ||
return getDefaultWindowLocation(); | ||
} | ||
if (typeof window.location !== "undefined") { | ||
// Browsers place location on window | ||
return window.location; | ||
} | ||
if ((typeof window.window !== "undefined") && (typeof window.window.location !== "undefined")) { | ||
// React Native on Android places location on window.window | ||
return window.window.location; | ||
} | ||
return getDefaultWindowLocation(); | ||
} | ||
var wloc = getWindowLocation(); | ||
var rCurrLoc = new RegExp("^" + wloc.protocol + "//" + wloc.host); | ||
@@ -27,0 +51,0 @@ |
{ | ||
"name": "sinon", | ||
"description": "JavaScript test spies, stubs and mocks.", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"homepage": "http://sinonjs.org/", | ||
@@ -6,0 +6,0 @@ "author": "Christian Johansen", |
@@ -114,4 +114,4 @@ # Sinon.JS | ||
##Licence | ||
## Licence | ||
Sinon.js was released under [BSD-3](LICENSE) |
Sorry, the diff of this file is not supported yet
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6335954
61012