I'm trying to test a service in my AngularJS project. All I'm trying to do is see if the method on my service has called through. I thought that when you use 'and.callThrough()' in jasmine it called the method for you and then you can see if it was called. However, when I test my function karma is giving me the response of 'Expected spy of getArtists to have been called'.
describe('Practice', function(){
beforeEach(module('MyApp'));
var ctrl, loadArtists, rootscope, dataFactory;
beforeEach(inject(function($controller, $rootScope, DataFactory){
spyOn(DataFactory, 'getArtists').and.callThrough();
dataFactory = DataFactory
rootscope = $rootScope;
scope = rootscope.$new();
ctrl = $controller('LaunchCtrl',{scope: scope, artistsPicsRotate: []});
}));
it('should do nothing',function(){
expect(ctrl.artistsPicsRotate).toEqual([])
});
it('should call through DataFactory', function(){
expect(dataFactory.getArtists).toHaveBeenCalled();
expect(dataFactory.getArtists.calls.count()).toEqual(1);
});
});
Any ideas on why this isn't working would be much appreciated.