Hi, i want to declare all the mocks i want to use on my tests and 
dinamically fake the services the problem is that i can see the way to get 
the services i want to mock. I'll give an example to try to explain it 
better:
(function(){
var myMocks;
function resolveService(serviceName){
//I DON'T KNOW WHO TO RESOLVE THE SERVICE HAVING IT'S NAME.
}
describe('the feature im going to tests',function(){//Using mocha to build 
the tests
//the tests...
beforeEach(module('moduleName'));
beforeEach(function(){//here is where i swap the real implementation with 
the mock
_.each(myMocks, function (serviceMethodsStub, serviceName) {//using lodash 
to iterate each mymocksProperty
                var srv = resolveService(serviceName);
                _.each(serviceMethodsStub, function (fxStub, fxName) {
sinon.stub(srv, fxName, fxStub)//using sinon to stub the methods
                });
            })
});
afterEach(function(){//after each i restore all the services mocked
_.each(myMocks, function (serviceMethodsStub, serviceName) {//using lodash 
to iterate each mymocksProperty
                var srv = resolveService(serviceName);
                _.each(serviceMethodsStub, function (fxStub, fxName) {
                    if (_.isFunction(srv[fxName].restore)) 
srv[fxName].restore();
                });
            });
})
});
myMocks = {
oneComponentIwanToMock:{
oneMethodIWantToMOck:function(){/*mock implementation*/}
otherMethodIWantToMOck:function(){/*mock implementation*/}
},
otherMethodIWantToMock:{
//...
}
}
})()
Any help would be appreciate. thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to