From c983907061ac67ff3a03ae9071370cad5b3315e8 Mon Sep 17 00:00:00 2001 From: biohazardpb4 Date: Mon, 13 Jan 2014 21:47:07 -0500 Subject: [PATCH] fix(ngMockE2E): added function parameter to $delegate on request passThrough The ngMockE2E $httpBackend has a mechanism to allows requests to pass through if one wants to send a real http request instead of mocking. The responseType of the request was never passed through to the real http module, as it was missing in the function parameter list. closes #5415 --- src/ngMock/angular-mocks.js | 6 ++++-- test/ngMock/angular-mocksSpec.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index e13675d72bb0..b09198fb0ec4 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1110,7 +1110,9 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { } // TODO(vojta): change params to: method, url, data, headers, callback - function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) { + function $httpBackend( + method, url, data, callback, headers, timeout, withCredentials, responseType) { + var xhr = new MockXhr(), expectation = expectations[0], wasExpected = false; @@ -1169,7 +1171,7 @@ function createHttpBackendMock($rootScope, $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); + $delegate(method, url, data, callback, headers, timeout, withCredentials, responseType); } else throw new Error('No response defined !'); return; } diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 80580fb10d21..e5b3f6969a42 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -1383,10 +1383,10 @@ describe('ngMockE2E', function() { describe('passThrough()', function() { it('should delegate requests to the real backend when passThrough is invoked', function() { hb.when('GET', /\/passThrough\/.*/).passThrough(); - hb('GET', '/passThrough/23', null, callback, {}, null, true); + hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob'); expect(realHttpBackend).toHaveBeenCalledOnceWith( - 'GET', '/passThrough/23', null, callback, {}, null, true); + 'GET', '/passThrough/23', null, callback, {}, null, true, 'blob'); }); });