fix(ngMocks): pass eventHandlers to $httpBackend if passThrough is active
Closes #14471
This commit is contained in:
committed by
Martin Staffa
parent
d2ec9d7184
commit
253cb8d4e9
Vendored
+1
-1
@@ -1393,7 +1393,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
|
||||
// if $browser specified, we do auto flush all requests
|
||||
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
|
||||
} else if (definition.passThrough) {
|
||||
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
|
||||
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers);
|
||||
} else throw new Error('No response defined !');
|
||||
return;
|
||||
}
|
||||
|
||||
Vendored
+6
-3
@@ -2133,11 +2133,14 @@ describe('ngMockE2E', function() {
|
||||
|
||||
describe('passThrough()', function() {
|
||||
it('should delegate requests to the real backend when passThrough is invoked', function() {
|
||||
var eventHandlers = {progress: angular.noop};
|
||||
var uploadEventHandlers = {progress: angular.noop};
|
||||
|
||||
hb.when('GET', /\/passThrough\/.*/).passThrough();
|
||||
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
|
||||
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob', eventHandlers, uploadEventHandlers);
|
||||
|
||||
expect(realHttpBackend).toHaveBeenCalledOnceWith(
|
||||
'GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
|
||||
'GET', '/passThrough/23', null, callback, {}, null, true, 'blob', eventHandlers, uploadEventHandlers);
|
||||
});
|
||||
|
||||
it('should be able to override a respond definition with passThrough', function() {
|
||||
@@ -2146,7 +2149,7 @@ describe('ngMockE2E', function() {
|
||||
hb('GET', '/passThrough/23', null, callback, {}, null, true);
|
||||
|
||||
expect(realHttpBackend).toHaveBeenCalledOnceWith(
|
||||
'GET', '/passThrough/23', null, callback, {}, null, true, undefined);
|
||||
'GET', '/passThrough/23', null, callback, {}, null, true, undefined, undefined, undefined);
|
||||
});
|
||||
|
||||
it('should be able to override a respond definition with passThrough', inject(function($browser) {
|
||||
|
||||
Reference in New Issue
Block a user