I have a file named signup.js
, which includes a function called demo()
. This function makes a call to another YUI library function with the following arguments:
Y.io('mywrongserver', callbackfunction);
I need to test this function, but I want to modify it to make the call to the correct server instead.
Y.io('myrightserver', callbackfunction);
Is there a way to achieve this without changing any code in signup.js
, since it was written by someone else?
Can mocking be used for this purpose?
The original code looks like this:
signup.js
demo : function(){
alert('i am inside demo');
// Some other stuff
callback = {
on :{
success:function(x,o){
// Some stuff here
}
}
}
// Now making a call to the wrong server
Y.io("mywrongserver", callback);
test.js
// Using JSMOCKITO APIs for YUI
testDemo = function(){
// Need to test the demo function in signup.js, ensuring that Y.io calls the right server
}
Thank you