Skip to content

Instantly share code, notes, and snippets.

@mrgenixus
Created August 3, 2017 17:03
Show Gist options
  • Save mrgenixus/9730d7c25a3724c02d80b5cc31928b40 to your computer and use it in GitHub Desktop.
Save mrgenixus/9730d7c25a3724c02d80b5cc31928b40 to your computer and use it in GitHub Desktop.
spai
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