I have the following methods.. I’d like to be able to mock something up so I can test whether or not pete() has been called. Not sure how to do this when im using closures. Any ideas ?
bla = (function(){
var a = 0;
jim = function(){
if(a==1){
pete();
}
},
pete = function(){
return 1;
}
var publicInterface = {
"publicjim": jim
}
return publicInterface;
})();
In your self-executing anonymous function, you’re using object propertys.
jimandpeteneed to be local variables in order to “hide” them via closure.