I am trying to write a test for angularjs which is mocking $httpBackend. Following is the test.
describe('test', function() {
beforeEach(function (){
module('abcApp');
});
var $httpBackend, filterService;
beforeEach(inject(function($injector) {
$httpBackend = $injector.get('$httpBackend');
filterService = $injector.get('filterService');
}));
it('getCompany calls get on http with correct parameter', function () {
$httpBackend.when('GET', 'api/Abc').respond([]);
filterService.getAbc();
$httpBackend.flush();
expect($httpBackend.get).toHaveBeenCalled();
});
});
when I run the test I get the following error:- Error: Expected a spy, but got undefined.
Any ideas how I would I assert that $httpBackend.get have been called with required parameter using expect.