There are several questions similar to this one, but none of them quite match the scenario I'm dealing with.
The situation involves a function that takes another function as a parameter:
var myfunc = (func_outer) => {
return func_outer().func_inner();
}
In my unit tests, I want to create a stub for a function called myfunc2. Essentially, I need to stub a nested stub. Currently, I manually create the stub like this, but I'd prefer to use sinon stubs if there's a better way:
const func_outer = () => {
return {
func_inner: () => {return mockResponse;}
}
};
Has anyone else encountered this particular situation before? Is there a simple solution to address this issue?