Since you use jasmine, there is an alternative way to mock calls with jasmine spies ( https://jasmine.imtqy.com/2.0/introduction.html#section-Spies ).
Using them, you can target function calls and, if necessary, enable end-to-end calls. This avoids clogging the top of the test file with $ provision and mock.
At the beginning of each test, I would have something like:
var mySchedule, myWarehouse; beforeEach(inject(function(schedule, warehouse) { mySchedule = schedule; myWarehouse = warehouse; spyOn(mySchedule, 'isShopOpen').and.callFake(function() { return true; }); spyOn(myWarehouse, 'numAvailableSweets').and.callFake(function() { return 10; }); }));
and this should work similarly to the $ provision mechanism, noting that you need to provide local instances of the injected variables that will track.
bwobbones Mar 23 '17 at 14:42 2017-03-23 14:42
source share