I usually create my javascript "controllers" in the following way:
var module = (function(){
function init(someService){
someService.doSomething();
}
return {
init: init
};
})();
module.init(SomeService);
I've just stumbled upon dependency injetion in javascript (e.g. JavaScript Dependency Injection).
What I would like to know is, from a testing point of view, is there any advantage using the Injector
in my link to inject mocks and such, versus simply passing them do the init
function like I do above.
To elaborate, I could just pass a SomeService
mock when I initialize my tests today. So is there any point for me to use the Injector
or something similar?