I have a service which is being tested:
angular.module('services', []).
service('myService', function(topService) {});
And the topService
is another angularjs service.
Now I want to write unit test for myService
, but I need to mock the topService
and pass it to myService.
I tried but not sure how to make it work:
define(['angular', 'angularMocks', 'services/my'], function(_, mocks, _) {
beforeEach(mocks.module('services'));
describe("my service", function() {
it("should do something", mocks.inject(function(myService) {
// how to mock and inject a `topService` to `myService` ????
expect(myService).doSomething().toEqual("???");
}));
});
});
How to do that?