2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/unit/core/transformData.test.js
T
Jay d905b7598d refactor: refresh test suite to be modernised (#7489)
* chore: port karma tests

* chore: port karma tests

* chore: port karma tests

* chore: tests

* chore: tests

* chore: tests

* chore: fix issues with port collisions

* refactor: utils tests

* refactor: utils tests

* refactor: utils tests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: tests to vitests

* refactor: ci

* chore: install pw deps

* chore: fixx ai feedback

* chore: wip compatability tests

* chore: wip compatability tests

* chore: wip compatability tests

* refactor: wip smoke

* chore: smoke test run

* chore: update unzip

* chore: update testing

* chore: update testing

* chore: update testing

* chore: update testing

* chore: update testing

* chore: skip tests that cannot run on node 16 and lower

* chore: fix 16x under tests

* chore: rest of tests

* fix: functions and runs

* feat: added tests for esm smoke

* feat: added smoke

* chore: ignore ai gen plans

* chore: ci fixes

* chore: fix small p2s
2026-03-12 15:27:09 +02:00

50 lines
1.1 KiB
JavaScript

import { describe, it, expect } from 'vitest';
import transformData from '../../../lib/core/transformData.js';
describe('core::transformData', () => {
it('supports a single transformer', () => {
const data = transformData.call({}, (value) => {
value = 'foo';
return value;
});
expect(data).toBe('foo');
});
it('supports an array of transformers', () => {
const data = transformData.call({ data: '' }, [
(value) => value + 'f',
(value) => value + 'o',
(value) => value + 'o',
]);
expect(data).toBe('foo');
});
it('passes headers through to transformers', () => {
const headers = {
'content-type': 'foo/bar',
};
const data = transformData.call(
{
data: '',
headers,
},
[(value, currentHeaders) => value + currentHeaders['content-type']]
);
expect(data).toBe('foo/bar');
});
it('passes status code through to transformers', () => {
const data = transformData.call(
{},
[(value, _headers, status) => value + status],
{ data: '', status: 200 }
);
expect(data).toBe('200');
});
});