I have a spyOn on object's field:
const object = { function?: Function }
spyOn(object, 'function').and.returnValue(Promise.resolve(result));
method I want to test uses this function
If it is used this way:
object.function!();
then it works properly
but if it is used like this:
const func = object.function;
if(!func)
return;
func();
then spy isn't called How to properly make a setup of spy in the second approach?
Aucun commentaire:
Enregistrer un commentaire