I am trying to write a Qunit test for a javascript closure function (testQUnit) using sinon library for mocking and spying on the function but it is not able to spy on the below closure.
Closure function:
var testQUnit = (function() {
return {
script :{
test1 : function(){
console.log('test');
}
}
}
})();
Test1 :
QUnit.test( "testQUnit", sinon.test(function( assert ) {
var returnScript= testQUnit.script;
var spy = this.spy(returnScript,'test1');
testQUnit.scripts.test1();
assert(spy.callCount,1);
}));
Error: Died on test #1 undefined: [object Object] is not a function.
Test2 :
QUnit.test( "testQUnit", sinon.test(function( assert ) {
//var returnScript= testQUnit.script;
var spy = this.spy(testQUnit,'script.test1');
testQUnit.scripts.test1();
assert(spy.callCount,1);
}));
Error: Died on test #1 undefined: Attempted to wrap undefined property script.test1 as function.
Frederick Sieber
There are a variety of completely reasonable reasons to trace a cell phone. Check out their post if you want to track a cell phone for free because you only have a few options and they all have limited features. It could be to keep an eye on your youngster online, ensure that employees are on task, or discover whether your partner is cheating.