Created
May 17, 2016 07:08
-
-
Save wolframkriesing/311b8b84289571d6fbe11d0a8e815d2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const buildFunctionSpy = ({ returnValue = void 0 } = {}) => { | |
const spy = (...args) => { | |
spy.wasCalled = true; | |
spy.lastCallArgs = args; | |
spy.allCallsArgs.push(args); | |
spy.callCount++; | |
return returnValue; | |
}; | |
spy.wasCalled = false; | |
spy.lastCallArgs = null; | |
spy.allCallsArgs = []; | |
spy.callCount = 0; | |
return spy; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment