Last active
February 5, 2019 23:36
-
-
Save todgru/547e4c79e97935de95382df57d465aed 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
function foo() { | |
console.log('foo'); | |
} | |
function bar() { | |
foo(); | |
} | |
module.exports = { | |
foo, | |
bar | |
} |
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
// better? | |
function foo() { | |
console.log('foo'); | |
} | |
module.exports = { | |
foo, | |
bar: foo | |
} |
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
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