fix(ngMock): keep withCredentials on passThrough

When using passThrough() and specifying withCredentials on the $http
call, the option is now passed to the underlying $httpBackend.
This commit is contained in:
Étienne Barrié 2013-07-31 14:50:56 +02:00 committed by Jeff Cross
parent 3c0c7165e2
commit 3079a6f4e0
2 changed files with 4 additions and 4 deletions

View file

@ -1045,7 +1045,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
}
// TODO(vojta): change params to: method, url, data, headers, callback
function $httpBackend(method, url, data, callback, headers, timeout) {
function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
var xhr = new MockXhr(),
expectation = expectations[0],
wasExpected = false;
@ -1103,7 +1103,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);
$delegate(method, url, data, callback, headers, timeout, withCredentials);
} else throw Error('No response defined !');
return;
}

View file

@ -1088,10 +1088,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);
hb('GET', '/passThrough/23', null, callback, {}, null, true);
expect(realHttpBackend).toHaveBeenCalledOnceWith(
'GET', '/passThrough/23', null, callback, undefined, undefined);
'GET', '/passThrough/23', null, callback, {}, null, true);
});
});