unexpected-sinon
Advanced tools
Comparing version 10.8.1 to 10.8.2
@@ -137,5 +137,12 @@ /*global location*/ | ||
} catch (e) {} | ||
var call = spy.getCall(j); | ||
if (call.stack) { | ||
call.stack = null; | ||
} | ||
if (call.errorWithCallStack) { | ||
call.errorWithCallStack.stack = null; | ||
} | ||
var expectedSpyCallSpec = { | ||
proxy: spy, | ||
call: spy.getCall(j), | ||
call: call, | ||
args: spy.args[j], | ||
@@ -267,3 +274,3 @@ callId: spy.callIds[j], | ||
suffix: function (output, value) { | ||
var stackFrames = value.getStackFrames && value.getStackFrames(); | ||
var stackFrames = value.stack && value.stack.split('\n').slice(3); | ||
if (Array.isArray(stackFrames) && stackFrames.length > 0) { | ||
@@ -270,0 +277,0 @@ output.sp().jsComment('at ' + makePathsRelativeToCwdOrLocation(stackFrames[0].replace(/^\s*(?:at\s+|@)?/, ''))); |
{ | ||
"name": "unexpected-sinon", | ||
"version": "10.8.1", | ||
"version": "10.8.2", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"serve": "*", | ||
"sinon": "1.17.7", | ||
"sinon": "2.3.7", | ||
"unexpected": "10.23.0", | ||
@@ -48,0 +48,0 @@ "unexpected-documentation-site-generator": "^4.5.0", |
@@ -20,8 +20,15 @@ // Monkey-patch sinon.create to patch all created spyCall instances | ||
var bogusStack = | ||
'Error\n' + | ||
'at theFunction (theFileName:xx:yy)\n' + | ||
'at theFunction (theFileName:xx:yy)\n' + | ||
'at theFunction (theFileName:xx:yy)'; | ||
function patchCall(call) { | ||
var getStackFrames = call && call.getStackFrames; | ||
if (getStackFrames) { | ||
call.getStackFrames = function () { | ||
return ['at theFunction (theFileName:xx:yy)']; | ||
}; | ||
if (call) { | ||
call.stack = bogusStack; | ||
if (call.errorWithCallStack) { | ||
call.errorWithCallStack = { stack: bogusStack }; | ||
} | ||
} | ||
@@ -34,13 +41,15 @@ return call; | ||
spy.getCall = function () { | ||
return patchCall(getCall.apply(spy, arguments)); | ||
var call = getCall.apply(spy, arguments); | ||
return patchCall(call); | ||
}; | ||
var getCalls = spy.getCalls; | ||
spy.getCalls = function () { | ||
return getCalls.call(spy).map(patchCall); | ||
var calls = getCalls.apply(spy, arguments); | ||
return calls.map(patchCall, this); | ||
}; | ||
} | ||
['spy', 'stub'].forEach(function (name) { | ||
var orig = sinon[name]; | ||
sinon[name] = function () { // ... | ||
function replace(name, obj) { | ||
var orig = obj[name]; | ||
obj[name] = function () { // ... | ||
var result = orig.apply(this, arguments); | ||
@@ -52,3 +61,8 @@ if (isSpy(result)) { | ||
}; | ||
sinon[name].create = orig.create; | ||
obj[name].create = orig.create; | ||
} | ||
['spy', 'stub'].forEach(function (name) { | ||
replace(name, sinon); | ||
replace(name, sinon.sandbox); | ||
}); | ||
@@ -55,0 +69,0 @@ |
423118
7551