fix(ngMocks): pass eventHandlers to $httpBackend if passThrough is active

Closes #14471
This commit is contained in:
andreyjkee
2016-04-20 11:11:01 +03:00
committed by Martin Staffa
parent d2ec9d7184
commit 253cb8d4e9
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -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;
}
+6 -3
View File
@@ -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) {