mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
@@ -112,6 +112,39 @@ describe('requests', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/mzabriskie/axios/issues/378
|
||||
it('should return JSON when rejecting', function (done) {
|
||||
var response;
|
||||
|
||||
axios('/api/account/signup', {
|
||||
username: null,
|
||||
password: null
|
||||
}, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
response = error.response;
|
||||
});
|
||||
|
||||
getAjaxRequest().then(function (request) {
|
||||
request.respondWith({
|
||||
status: 400,
|
||||
statusText: 'Bad Request',
|
||||
responseText: '{"error": "BAD USERNAME", "code": 1}'
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
expect(typeof response.data).toEqual('object');
|
||||
// expect(response.data.error).toEqual('BAD USERNAME');
|
||||
// expect(response.data.code).toEqual(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should make cross domian http request', function (done) {
|
||||
var response;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user