mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
fa337332b9
* chore: small fixes to tests * feat: transitional move to vitests * feat: moving unit tests in progress * feat: moving more unit tests over * feat: more tests moved * feat: updated more sections of the http test * chore: wip http tests * chore: wip http tests * chore: more http tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: tests * chore: remove un-needed docs * chore: update package lock * chore: update lock
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
/* eslint-env mocha */
|
|
import transformData from '../../../lib/core/transformData';
|
|
|
|
describe('core::transformData', function () {
|
|
it('should support a single transformer', function () {
|
|
let data;
|
|
|
|
data = transformData.call({}, function (data) {
|
|
data = 'foo';
|
|
return data;
|
|
});
|
|
|
|
expect(data).toEqual('foo');
|
|
});
|
|
|
|
it('should support an array of transformers', function () {
|
|
let data = '';
|
|
data = transformData.call({ data }, [
|
|
function (data) {
|
|
data += 'f';
|
|
return data;
|
|
},
|
|
function (data) {
|
|
data += 'o';
|
|
return data;
|
|
},
|
|
function (data) {
|
|
data += 'o';
|
|
return data;
|
|
},
|
|
]);
|
|
|
|
expect(data).toEqual('foo');
|
|
});
|
|
|
|
it('should support reference headers in transformData', function () {
|
|
const headers = {
|
|
'content-type': 'foo/bar',
|
|
};
|
|
let data = '';
|
|
data = transformData.call({ data, headers }, [
|
|
function (data, headers) {
|
|
data += headers['content-type'];
|
|
return data;
|
|
},
|
|
]);
|
|
|
|
expect(data).toEqual('foo/bar');
|
|
});
|
|
|
|
it('should support reference status code in transformData', function () {
|
|
let data = '';
|
|
data = transformData.call(
|
|
{},
|
|
[
|
|
function (data, headers, status) {
|
|
data += status;
|
|
return data;
|
|
},
|
|
],
|
|
{ data, status: 200 }
|
|
);
|
|
|
|
expect(data).toEqual('200');
|
|
});
|
|
});
|