lundi 6 juillet 2015

Is there a way to consolidate 'spyOn' setup in Jasmine test?

I'm doing some testing of Angular controllers with Jasmine and spying on almost a dozen methods. Is there any way to consolidate the spy setup? My current setup looks like:

spyOn(playersService, 'getInfo');
spyOn(playersService, 'getAccounts');
spyOn(playersService, 'getGames');
spyOn(playersService, 'getStatus');
spyOn(playersService, 'getEvents');
spyOn(viewersService, 'getViewers');
spyOn(helpersService, 'formatStats');
spyOn(helpersService, 'formatCounts');
spyOn(helpersService, 'formatValues');
spyOn(PlayerInfoController, 'slideToggle');
spyOn(PlayerInfoController, 'openModal');

This just strikes me as a lot of repeated code.

Aucun commentaire:

Enregistrer un commentaire