Skip to content

Commit e7a9cbe

Browse files
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 <[email protected]>
1 parent 51c1d7b commit e7a9cbe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/specs/transform.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,31 @@ describe('transform', function () {
197197
done();
198198
});
199199
});
200+
201+
it('should return response.data as parsed JSON object when responseType is json', function (done) {
202+
const instance = axios.create({
203+
baseURL: '/api',
204+
transformResponse: [function (data) {
205+
return data;
206+
}],
207+
responseType: 'json',
208+
});
209+
210+
instance.get("my/endpoint", { responseType: 'json' })
211+
.then(response => {
212+
expect(typeof response).toBe('object');
213+
done();
214+
})
215+
.catch(err => {
216+
done(err);
217+
});
218+
219+
getAjaxRequest().then(function (request){
220+
request.respondWith({
221+
status: 200,
222+
responseText: '{"key1": "value1"}'
223+
});
224+
});
225+
});
226+
200227
});

0 commit comments

Comments
 (0)