Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active February 5, 2019 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save todgru/547e4c79e97935de95382df57d465aed to your computer and use it in GitHub Desktop.
Save todgru/547e4c79e97935de95382df57d465aed to your computer and use it in GitHub Desktop.
function foo() {
console.log('foo');
}
function bar() {
foo();
}
module.exports = {
foo,
bar
}
// better?
function foo() {
console.log('foo');
}
module.exports = {
foo,
bar: foo
}
const test = require("ava");
const sinon = require("sinon");
let sandbox;
test.before(t => {
sandbox = sinon.sandbox.create();
});
test.beforeEach(t => {
});
test.afterEach.always(t => {
sandbox.restore();
});
test("bar() return 'fake'", async t => {
t.context.module = require('./module');
t.context.module.foo = sandbox.stub().return("fake");
// This will not call the stub, but the original method. ????
t.is(t.context.module.bar(), 'fake');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment