Hi, I am new to angularJS.
I use grunt and karma to develop simple web application and try to write tests whenever possible.
I use angular 1.2.0 rc2 (had the same problem with rc1) and have problem/answer I hope someone can answer me.
I have follwing test case, I have simplified it and reduced it:
it('should abort post request', inject(function($http, $q, $rootScope) {
var canceller = $q.defer();
$http({
method: 'POST',
url: '/xml',
data: '<ping/>',
timeout: canceller.promise,
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'Accept': 'application/xml'
}
});
$rootScope.$digest();
canceller.resolve(); //now the request should be aborted and no request should be pending...
$rootScope.$digest();
}));
If I run this test, I receive error "Unflushed requests: 1"
My question is:
Why is do I need to call $httpBackend.flush(); so the test can pass. The request should have been aborted, right?
Is there something I am missing?
Thank you for guidance
Michal