2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/smoke/cjs/tests/http2.smoke.test.cjs
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

87 lines
2.1 KiB
JavaScript

const axios = require('axios');
const { describe, it } = require('mocha');
const { expect } = require('chai');
describe('http2 compat (dist export only)', () => {
it('keeps instance-level httpVersion and http2Options in request config', async () => {
const client = axios.create({
baseURL: 'https://example.com',
httpVersion: 2,
http2Options: {
rejectUnauthorized: false,
},
});
const response = await client.get('/resource', {
adapter: async (config) => ({
data: {
httpVersion: config.httpVersion,
http2Options: config.http2Options,
},
status: 200,
statusText: 'OK',
headers: {},
config,
}),
});
expect(response.data.httpVersion).to.equal(2);
expect(response.data.http2Options).to.deep.equal({
rejectUnauthorized: false,
});
});
it('merges request http2Options with instance http2Options', async () => {
const client = axios.create({
baseURL: 'https://example.com',
httpVersion: 2,
http2Options: {
rejectUnauthorized: false,
sessionTimeout: 1000,
},
});
const response = await client.get('/resource', {
http2Options: {
sessionTimeout: 5000,
customFlag: true,
},
adapter: async (config) => ({
data: config.http2Options,
status: 200,
statusText: 'OK',
headers: {},
config,
}),
});
expect(response.data).to.deep.equal({
rejectUnauthorized: false,
sessionTimeout: 5000,
customFlag: true,
});
});
it('allows request-level httpVersion override', async () => {
const client = axios.create({
baseURL: 'https://example.com',
httpVersion: 2,
});
const response = await client.get('/resource', {
httpVersion: 1,
adapter: async (config) => ({
data: {
httpVersion: config.httpVersion,
},
status: 200,
statusText: 'OK',
headers: {},
config,
}),
});
expect(response.data.httpVersion).to.equal(1);
});
});