Created
August 3, 2017 17:03
-
-
Save mrgenixus/9730d7c25a3724c02d80b5cc31928b40 to your computer and use it in GitHub Desktop.
spai
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 function stub(obj, method, callback=_.noop, { as:name, returns }) { | |
beforeEach(function() { | |
const stub = this.sinon.stub(obj, 'method', (...args) => { | |
callback.call(this, ...args); | |
}); | |
if (returns) stub.returns(returns); | |
if (name) _.set(this, name, stub); | |
}); | |
} | |
export function spy(name) { | |
beforeEach(function() { | |
_.set(this, name, this.sinon.spy()); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment