diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 81da7ac..1fb5b2b 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -65,6 +65,7 @@ module.exports = function httpAdapter(resolve, reject, config) { config.transformResponse ), status: res.statusCode, + statusText: res.statusMessage, headers: res.headers, config: config }; diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 3ff6861..2e4106f 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -42,6 +42,7 @@ module.exports = function xhrAdapter(resolve, reject, config) { config.transformResponse ), status: request.status, + statusText: request.statusText, headers: headers, config: config }; diff --git a/test/specs/wrapper.spec.js b/test/specs/wrapper.spec.js index b81a91a..f1cde3a 100644 --- a/test/specs/wrapper.spec.js +++ b/test/specs/wrapper.spec.js @@ -146,6 +146,38 @@ describe('wrapper', function () { }, 0); }); + it('should supply correct response', function (done) { + var request, response; + + axios({ + method: 'post', + url: '/foo' + }).then(function (res) { + response = res; + }); + + setTimeout(function () { + request = jasmine.Ajax.requests.mostRecent(); + + request.respondWith({ + status: 200, + statusText: 'OK', + responseText: '{"foo": "bar"}', + headers: { + 'Content-Type': 'application/json' + } + }); + + setTimeout(function () { + expect(response.data.foo).toEqual('bar'); + expect(response.status).toEqual(200); + expect(response.statusText).toEqual('OK'); + expect(response.headers['content-type']).toEqual('application/json'); + done(); + }, 0); + }, 0); + }); + it('should support array buffer response', function (done) { var request, response;