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

Commit ea6c247

Browse files
biohazardpb4gkalpak
biohazardpb4
authored andcommitted
fix(ngMockE2E): pass responseType to $delegate when using passThrough
The `ngMockE2E` `$httpBackend` has a mechanism to allow requests to pass through, if one wants to send a real HTTP request instead of mocking. The specified `responseType` of the request was never passed through to the "real" `$httpBackend` (of the `ng` module), resulting in it being effectively ignored. Fixes #5415 Closes #5783
1 parent b43768a commit ea6c247

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/ngMock/angular-mocks.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,8 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
13211321
}
13221322

13231323
// TODO(vojta): change params to: method, url, data, headers, callback
1324-
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
1324+
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType) {
1325+
13251326
var xhr = new MockXhr(),
13261327
expectation = expectations[0],
13271328
wasExpected = false;
@@ -1385,7 +1386,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
13851386
// if $browser specified, we do auto flush all requests
13861387
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
13871388
} else if (definition.passThrough) {
1388-
$delegate(method, url, data, callback, headers, timeout, withCredentials);
1389+
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
13891390
} else throw new Error('No response defined !');
13901391
return;
13911392
}

test/ngMock/angular-mocksSpec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2085,10 +2085,10 @@ describe('ngMockE2E', function() {
20852085
describe('passThrough()', function() {
20862086
it('should delegate requests to the real backend when passThrough is invoked', function() {
20872087
hb.when('GET', /\/passThrough\/.*/).passThrough();
2088-
hb('GET', '/passThrough/23', null, callback, {}, null, true);
2088+
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
20892089

20902090
expect(realHttpBackend).toHaveBeenCalledOnceWith(
2091-
'GET', '/passThrough/23', null, callback, {}, null, true);
2091+
'GET', '/passThrough/23', null, callback, {}, null, true, 'blob');
20922092
});
20932093

20942094
it('should be able to override a respond definition with passThrough', function() {
@@ -2097,7 +2097,7 @@ describe('ngMockE2E', function() {
20972097
hb('GET', '/passThrough/23', null, callback, {}, null, true);
20982098

20992099
expect(realHttpBackend).toHaveBeenCalledOnceWith(
2100-
'GET', '/passThrough/23', null, callback, {}, null, true);
2100+
'GET', '/passThrough/23', null, callback, {}, null, true, undefined);
21012101
});
21022102

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

0 commit comments

Comments
 (0)