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

fix(ngMock): Add responseType function parameter in mock httpbackend for passthrough #11524

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ function createHttpBackendMock($rootScope, $timeout, $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;
Expand Down Expand Up @@ -1193,7 +1193,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);
$delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
} else throw new Error('No response defined !');
return;
}
Expand Down
8 changes: 4 additions & 4 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,19 +1796,19 @@ 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, 'arraybuffer');

expect(realHttpBackend).toHaveBeenCalledOnceWith(
'GET', '/passThrough/23', null, callback, {}, null, true);
'GET', '/passThrough/23', null, callback, {}, null, true, 'arraybuffer');
});

it('should be able to override a respond definition with passThrough', function() {
var definition = hb.when('GET', /\/passThrough\/.*/).respond('override me');
definition.passThrough();
hb('GET', '/passThrough/23', null, callback, {}, null, true);
hb('GET', '/passThrough/23', null, callback, {}, null, true, 'arraybuffer');

expect(realHttpBackend).toHaveBeenCalledOnceWith(
'GET', '/passThrough/23', null, callback, {}, null, true);
'GET', '/passThrough/23', null, callback, {}, null, true, 'arraybuffer');
});

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