In my app.js file:
function foo(str)
{
return run_func(str)
}
function run_func(str)
{
return '1'
}
exports._test = {foo: foo, run_func: run_func}
In my test.file I tried to mock the run_func.
app = require("./app.js")
describe('test', function(){
it('test', function(){
var foo_mock = sinon.mock(app._test)
foo_mock.expects('run_func').withArgs('a').returns('0')
var res = app._test.foo('a')
assert.equal('0', res)
})
})
apparently it does not call the desired mock, it calls the original run_func() How can I let it call the mocked function?
Aucun commentaire:
Enregistrer un commentaire