To inject a fake version of myService, and intercept calls to myMethod, do something like this:
Or check out the cool video here.
var myMethodFake = function() { ... };
beforeEach(function () {
module(function ($provide) {
mockMyService = {
myMethod: jasmine.createSpy('myMethod').andCallFake(myMethodFake)
};
$provide.value('myService', mockMyService);
});
});
it('does stuff', inject(function(myService) {
myService.myMethod();
});
No comments:
Post a Comment