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

Commit 4d82206

Browse files
committed
fixup! fix($http): correct behavior
1 parent 4578f25 commit 4d82206

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/ngMock/angular-mocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
13791379
if (!$browser && timeout) {
13801380
if (timeout.then) {
13811381
timeout.then(function() {
1382-
handlePrematureEnd(timeout.$$timeoutId >= 0 ? 'timeout' : 'abort');
1382+
handlePrematureEnd(angular.isDefined(timeout.$$timeoutId) ? 'timeout' : 'abort');
13831383
});
13841384
} else {
13851385
$timeout(function() {

test/ng/httpSpec.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,35 +1929,41 @@ describe('$http', function() {
19291929
var onFulfilled = jasmine.createSpy('onFulfilled');
19301930
var onRejected = jasmine.createSpy('onRejected').and.callFake(function(response) {
19311931
expect(response.xhrStatus).toBe('timeout');
1932-
callback();
19331932
});
19341933

19351934
$httpBackend.expect('GET', '/some').respond(200);
19361935

1937-
$http({method: 'GET', url: '/some', timeout: 10}).then(onFulfilled, onRejected);
1936+
$http({
1937+
method: 'GET',
1938+
url: '/some',
1939+
timeout: 10
1940+
}).then(onFulfilled, onRejected);
19381941

19391942
$timeout.flush(100);
19401943

19411944
expect(onFulfilled).not.toHaveBeenCalled();
1942-
expect(callback).toHaveBeenCalled();
1945+
expect(onRejected).toHaveBeenCalled();
19431946
}));
19441947

19451948

19461949
it('should reject promise when timeout promise resolves', inject(function($timeout) {
19471950
var onFulfilled = jasmine.createSpy('onFulfilled');
19481951
var onRejected = jasmine.createSpy('onRejected').and.callFake(function(response) {
19491952
expect(response.xhrStatus).toBe('timeout');
1950-
callback();
19511953
});
19521954

19531955
$httpBackend.expect('GET', '/some').respond(200);
19541956

1955-
$http({method: 'GET', url: '/some', timeout: $timeout(noop, 10)}).then(onFulfilled, onRejected);
1957+
$http({
1958+
method: 'GET',
1959+
url: '/some',
1960+
timeout: $timeout(noop, 10)
1961+
}).then(onFulfilled, onRejected);
19561962

19571963
$timeout.flush(100);
19581964

19591965
expect(onFulfilled).not.toHaveBeenCalled();
1960-
expect(callback).toHaveBeenCalled();
1966+
expect(onRejected).toHaveBeenCalled();
19611967
}));
19621968
});
19631969

0 commit comments

Comments
 (0)