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

Commit 253cb8d

Browse files
andreyjkeeNarretz
authored andcommitted
fix(ngMocks): pass eventHandlers to $httpBackend if passThrough is active
Closes #14471
1 parent d2ec9d7 commit 253cb8d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/ngMock/angular-mocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
13931393
// if $browser specified, we do auto flush all requests
13941394
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
13951395
} else if (definition.passThrough) {
1396-
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
1396+
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers);
13971397
} else throw new Error('No response defined !');
13981398
return;
13991399
}

test/ngMock/angular-mocksSpec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,11 +2133,14 @@ describe('ngMockE2E', function() {
21332133

21342134
describe('passThrough()', function() {
21352135
it('should delegate requests to the real backend when passThrough is invoked', function() {
2136+
var eventHandlers = {progress: angular.noop};
2137+
var uploadEventHandlers = {progress: angular.noop};
2138+
21362139
hb.when('GET', /\/passThrough\/.*/).passThrough();
2137-
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
2140+
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob', eventHandlers, uploadEventHandlers);
21382141

21392142
expect(realHttpBackend).toHaveBeenCalledOnceWith(
2140-
'GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
2143+
'GET', '/passThrough/23', null, callback, {}, null, true, 'blob', eventHandlers, uploadEventHandlers);
21412144
});
21422145

21432146
it('should be able to override a respond definition with passThrough', function() {
@@ -2146,7 +2149,7 @@ describe('ngMockE2E', function() {
21462149
hb('GET', '/passThrough/23', null, callback, {}, null, true);
21472150

21482151
expect(realHttpBackend).toHaveBeenCalledOnceWith(
2149-
'GET', '/passThrough/23', null, callback, {}, null, true, undefined);
2152+
'GET', '/passThrough/23', null, callback, {}, null, true, undefined, undefined, undefined);
21502153
});
21512154

21522155
it('should be able to override a respond definition with passThrough', inject(function($browser) {

0 commit comments

Comments
 (0)