我有一个使用本地函数的 Angular 服务并执行以下工作:
function myService($http,$q){
var myService = {};
var _localService = function (Table) {
return Table.something;
}
var _getSomething = function () {
return _localService('someTable');
}
var _getSomethingElse = function () {
return _localService('someTable2');
}
myService.getSomething = _getSomething ;
myService.getSomethingElse = _getSomethingElse ;
return myService ; }
现在我想用 jasmine 测试我的服务,并且我想测试是否调用了 localService。像这样的东西:
spyOn(myService,"_localService");
myService.getSomething();
expect(myService._localService).toHaveBeenCalled();
我该怎么做,请帮忙。