mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-16 10:23:51 +08:00
test($http): test that timed out $http request rejects promise
Closes #7688 Closes #7686
This commit is contained in:
@@ -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();
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user