2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +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:
Naron
2025-02-02 09:33:16 -05:00
committed by GitHub
parent 51c1d7ba9d
commit e7a9cbe3be
+27
View File
@@ -197,4 +197,31 @@ describe('transform', function () {
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"}'
});
});
});
});