mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
test(transform): add test case for issue 5853 on response type to 'json' (#5901)
* test(transform): add test case for issue 5853 on response type to 'json' * test(transform): formatted second argument --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -197,4 +197,31 @@ describe('transform', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return response.data as parsed JSON object when responseType is json', function (done) {
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: '/api',
|
||||||
|
transformResponse: [function (data) {
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
responseType: 'json',
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.get("my/endpoint", { responseType: 'json' })
|
||||||
|
.then(response => {
|
||||||
|
expect(typeof response).toBe('object');
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
getAjaxRequest().then(function (request){
|
||||||
|
request.respondWith({
|
||||||
|
status: 200,
|
||||||
|
responseText: '{"key1": "value1"}'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user