Skip to content

Commit c31fcc6

Browse files
committed
fix(ngMock): Add responseType function parameter in mock httpbackend for
passthrough The ngMock $httpBackend allows http request routes that have not been defined for mocking to be passed through to the real http backend service. The responseType parameter was missing in the ngMock httpbackend parameter list. closes angular#5415
1 parent 73ab107 commit c31fcc6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ngMock/angular-mocks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
11291129
}
11301130

11311131
// TODO(vojta): change params to: method, url, data, headers, callback
1132-
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
1132+
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType) {
11331133
var xhr = new MockXhr(),
11341134
expectation = expectations[0],
11351135
wasExpected = false;
@@ -1193,7 +1193,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
11931193
// if $browser specified, we do auto flush all requests
11941194
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
11951195
} else if (definition.passThrough) {
1196-
$delegate(method, url, data, callback, headers, timeout, withCredentials);
1196+
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
11971197
} else throw new Error('No response defined !');
11981198
return;
11991199
}

test/ngMock/angular-mocksSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1796,10 +1796,10 @@ describe('ngMockE2E', function() {
17961796
describe('passThrough()', function() {
17971797
it('should delegate requests to the real backend when passThrough is invoked', function() {
17981798
hb.when('GET', /\/passThrough\/.*/).passThrough();
1799-
hb('GET', '/passThrough/23', null, callback, {}, null, true);
1799+
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'arraybuffer');
18001800

18011801
expect(realHttpBackend).toHaveBeenCalledOnceWith(
1802-
'GET', '/passThrough/23', null, callback, {}, null, true);
1802+
'GET', '/passThrough/23', null, callback, {}, null, true, 'arraybuffer');
18031803
});
18041804

18051805
it('should be able to override a respond definition with passThrough', function() {

0 commit comments

Comments
 (0)