Attempting to setup a unit test for an AngularJS controller that utilizes a service making a $http.get
call. Despite using $httpBackend.expectGET
followed by $httpBackend.flush()
, the application is attempting to make GET requests for template HTML resources, resulting in an unexpected request error.
beforeEach(inject(function($injector){
controller = $injector.get('$controller');
scope = $injector.get('$rootScope').$new();
httpBackend = $injector.get('$httpBackend');
httpBackend.whenGET(UrlPrefix+"/promotions/default.json").respond("yeh");
}));
it("should fetch promotions", function() {
httpBackend.expectGET(UrlPrefix+"/promotions/default.json");
Controller = controller('promotionsController', {
$scope: scope
});
scope.getPromotions();
httpBackend.flush();
});
Encountering:
Unexpected request : GET ./template/loader/app-loader.html
This template should be loaded before the controller. Any suggestions on how to bypass these template GET requests?