test($http): test that timed out $http request rejects promise

Closes #7688
Closes #7686
This commit is contained in:
Caitlin Potter
2014-06-03 21:30:48 -04:00
parent 6ffd53ee3c
commit 2e0464fba4

View File

@@ -1427,6 +1427,20 @@ describe('$http', function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
}));
it('should reject promise when timeout promise resolves', inject(function($timeout) {
var onFulfilled = jasmine.createSpy('onFulfilled');
var onRejected = jasmine.createSpy('onRejected');
$httpBackend.expect('GET', '/some').respond(200);
$http({method: 'GET', url: '/some', timeout: $timeout(noop, 10)}).then(onFulfilled, onRejected);
$timeout.flush(100);
expect(onFulfilled).not.toHaveBeenCalled();
expect(onRejected).toHaveBeenCalledOnce();
}));
});