Stubbing nested function calls in sinon

Viewed 8873

There are three seperate questions that are similar to this one but none of them resembles the case I have.

So I basically have a function which takes a function as a parameter

var myfunc ( func_outer ) {
    return func_outer().func_inner();
}

In my unit tests I want to be able to make a stub of a myfunc2. Basically I need to be able to stub a stub which is a nested stub. I currently use this kind of a manual stub but I would rather do it using sinon stubs if there is a way.

const func_outer = () => {
    return {
       func_inner: () => {return mockResponse;}
    }
};

Has anyone ever faced this situation. Is there an easy way to solve this issue?

1 Answers
Related