From 2e0464fba4ced5e561e26ee604ebf7671b955363 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 3 Jun 2014 21:30:48 -0400 Subject: [PATCH] test($http): test that timed out $http request rejects promise Closes #7688 Closes #7686 --- test/ng/httpSpec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 14ac8433..e996c6df 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -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(); + })); });