Skip to content

Instantly share code, notes, and snippets.

@ronco
Last active September 16, 2015 18:25
Show Gist options
  • Save ronco/99ba6c2192b4e45d7f5b to your computer and use it in GitHub Desktop.
Save ronco/99ba6c2192b4e45d7f5b to your computer and use it in GitHub Desktop.
import handyMethods from 'handy-methods';
describe('handyMethods', function() {
describe('methodB', function() {
it("delegates to methodA", function() {
let methodAStub = sinon.stub(handyMethods, 'methodB');
methodAStub.returns('not foo');
expect(methodB('bar')).to.equal('not foo');
})
})
});
var methodA = function(arg) {
// complex logic here
return 'foo';
};
var methodB = function(arg) {
// complex logic here
return methodA(arg);
};
export {
methodA,
methodB
};
@ronco
Copy link
Author

ronco commented Sep 16, 2015

The call to methodA in methodB is always the closure value of methodA. In node module land I could restub that value using rewire. I'm not sure how to do it in ES2015 babel land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment