the helpers are scoped inside the plugin, which is an anonymous function , and you cannot access the variables declared inside it.
If you want to test it, drop the var
keyword in front of the functions. That will declare the functions as global (will attach them to the window object), giving them the ability to be visible from the window scope ( by calling someHelperFunction
or window.someHelperFunction
).
so, for testing :
(function($) {
someHelperFunction = function(s, d) {
return s*d;
}
someOtherHelperFunction = function(s) {
return s*2;
}
// here goes the normal plugin code
})(jQuery);
after the testing is over, add the var
keyword again.
Update
I think that a better approach would be to group your testable functions in an object - and construct an api. Then, on the same principle, you could make that api visible in the global scope or not:
(function($, global) {
someHelperFunction = function(s, d) {
return s*d;
}
someOtherHelperFunction = function(s) {
return s*2;
}
var api = {
someHelperFunction: someHelperFunction,
someOtherHelperFunction: someOtherHelperFunction
};
// decide whether you want to expose your api or not
if(makeGlobal) {
global.api = api;
}
})(jQuery, this);