Consider a class which I want to test
class A{
private b:B = new B();
function someFunction(){
b.someOtherFunction(); // prevent this call
return 42;
}
}
Class B{
function someOtherFunction(){
//does stuff
}
}
Now I want to test someFunction of class A, how do I prevent someOtherFunction of class B, being called. I do not have access to object b, since it is private.
const a = new A();
describe("A",()=>{
it("test someFunction", ()=>{
sinon.stub(B,"someOtherFunction").resolves()
// test someFunction here
})
})
wont work because sinon.stub expects the object b, not the class B.