diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index d52e6bcf..43006fef 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1142,7 +1142,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { return function() { return angular.isNumber(status) ? [status, data, headers, statusText] - : [200, status, data]; + : [200, status, data, headers]; }; } diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 68fb18ee..c22c95f4 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -1059,17 +1059,6 @@ describe('ngMock', function() { expect(callback).toHaveBeenCalledOnceWith(200, 'first', 'header: val', 'OK'); }); - it('should take function', function() { - hb.expect('GET', '/some').respond(function(m, u, d, h) { - return [301, m + u + ';' + d + ';a=' + h.a, {'Connection': 'keep-alive'}, 'Moved Permanently']; - }); - - hb('GET', '/some', 'data', callback, {a: 'b'}); - hb.flush(); - - expect(callback).toHaveBeenCalledOnceWith(301, 'GET/some;data;a=b', 'Connection: keep-alive', 'Moved Permanently'); - }); - it('should default status code to 200', function() { callback.andCallFake(function(status, response) { expect(status).toBe(200); @@ -1085,6 +1074,24 @@ describe('ngMock', function() { expect(callback.callCount).toBe(2); }); + it('should default status code to 200 and provide status text', function() { + hb.expect('GET', '/url1').respond('first', {'header': 'val'}, 'OK'); + hb('GET', '/url1', null, callback); + hb.flush(); + + expect(callback).toHaveBeenCalledOnceWith(200, 'first', 'header: val', 'OK'); + }); + + it('should take function', function() { + hb.expect('GET', '/some').respond(function(m, u, d, h) { + return [301, m + u + ';' + d + ';a=' + h.a, {'Connection': 'keep-alive'}, 'Moved Permanently']; + }); + + hb('GET', '/some', 'data', callback, {a: 'b'}); + hb.flush(); + + expect(callback).toHaveBeenCalledOnceWith(301, 'GET/some;data;a=b', 'Connection: keep-alive', 'Moved Permanently'); + }); it('should default response headers to ""', function() { hb.expect('GET', '/url1').respond(200, 'first');