I've mocked an httpBackend to test the following code.
self.Api.post('/endpoint/action/', actionData)
.then(function(resp){
result = _.get(resp, 'data.MessageList');
if(resp.status = 200 && result) {
for (var i = 0; i < result.length; i++) {
addResultMessage(result[i]);
}
}
});
I mocked my service doing the following:
beforeEach(function(){
angular.mock.module(function(ApiProvider) {
ApiProvider.setUrl('http://localhost:10010');
});
});
beforeEach(inject(function($rootScope, $controller, _$interval_, $q, $injector, $httpBackend){
$rootScope = $injector.get('$rootScope');
scope = $rootScope;
httpBackend = $httpBackend;
createController = function() {
return $controller('MyCtrl',{
$scope: scope,
$uibModalInstance: modalInstance,
$interval: _$interval_,
});
}
}));
Inside an it
httpBackend
.when('POST', 'http://localhost:10010/endpoint/action/')
.respond(200, mockedResponse);
I'm not getting any response when I do the POST to that endpoint. I don't get any error simply I don't get any resp callback