Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ff791c9

Browse files
committed
test($http): test that timed out $http request rejects promise
Closes #7688 Closes #7686
1 parent c97c5ce commit ff791c9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/ng/httpSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,20 @@ describe('$http', function() {
13081308
$httpBackend.verifyNoOutstandingExpectation();
13091309
$httpBackend.verifyNoOutstandingRequest();
13101310
}));
1311+
1312+
1313+
it('should reject promise when timeout promise resolves', inject(function($timeout) {
1314+
var onFulfilled = jasmine.createSpy('onFulfilled');
1315+
var onRejected = jasmine.createSpy('onRejected');
1316+
$httpBackend.expect('GET', '/some').respond(200);
1317+
1318+
$http({method: 'GET', url: '/some', timeout: $timeout(noop, 10)}).then(onFulfilled, onRejected);
1319+
1320+
$timeout.flush(100);
1321+
1322+
expect(onFulfilled).not.toHaveBeenCalled();
1323+
expect(onRejected).toHaveBeenCalledOnce();
1324+
}));
13111325
});
13121326

13131327

0 commit comments

Comments
 (0)