0
由於某些原因,當我運行測試時,Jasmine告訴我'DataFactory'未定義。任何想法爲什麼?當使用jasmine進行測試時,注入的服務不確定
describe('Practice', function(){
beforeEach(module('MyApp'));
var ctrl;
beforeEach(inject(function($controller, DataFactory){
spyOn(DataFactory, 'getArtists').andCallThrough();
ctrl = $controller('ArtistCtrl')
}));
it('should have array available on load', function(){
expect(DataFactory.getArtists).toHaveBeenCalled();
expect(DataFactory.getArtists.callCount).toEqual(1);
});
});
angular.module('MyApp')
.factory('DataFactory', ['$http', function($http){
return {
getArtists: function(){
return $http.get('artists.json');
}
}
}]);