このように定義されたサービスがあります:
angular.module("myApp")
.factory("myService.foo", function () {
// utterly delightful code
});
テストには Karma と Jasmine を使用しています。テストでは、ほとんどのサーバー テストで次のようなことを行っています。
describe('Service: someService', function () {
// load the service's module
beforeEach(module('myApp'));
// instantiate service
var _someService;
beforeEach(inject([function (someService) {
_someService = someService;
}]));
it('should do something', function () {
expect(!!_someService).toBe(true);
});
});
「myService.foo」のような名前のサービスで同じことをしようとすると、(もちろん) エラーがスローされます。
describe('Service: myService.foo', function () {
// load the service's module
beforeEach(module('myApp'));
// instantiate service
var _myService;
beforeEach(inject([function (myService.foo) {
_myService = myService.foo;
}]));
it('should do something', function () {
expect(!!_myService).toBe(true);
});
});
angularがサービス名を推測できないドット構文の明らかな問題のためです。このサービスを挿入してテストするにはどうすればよいですか? 不足している代替構文はありますか?