axios-axios/tests/unit/core/buildFullPath.test.js
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

35 lines
1.3 KiB
JavaScript

import { describe, it, expect } from 'vitest';
import buildFullPath from '../../../lib/core/buildFullPath.js';
describe('core::buildFullPath', () => {
it('combines URLs when the requested URL is relative', () => {
expect(buildFullPath('https://api.github.com', '/users')).toBe('https://api.github.com/users');
});
it('does not combine URLs when the requested URL is absolute', () => {
expect(buildFullPath('https://api.github.com', 'https://api.example.com/users')).toBe(
'https://api.example.com/users'
);
});
it('combines URLs when requested URL is absolute and allowAbsoluteUrls is false', () => {
expect(buildFullPath('https://api.github.com', 'https://api.example.com/users', false)).toBe(
'https://api.github.com/https://api.example.com/users'
);
});
it('does not combine URLs when baseURL is missing and allowAbsoluteUrls is false', () => {
expect(buildFullPath(undefined, 'https://api.example.com/users', false)).toBe(
'https://api.example.com/users'
);
});
it('does not combine URLs when baseURL is not configured', () => {
expect(buildFullPath(undefined, '/users')).toBe('/users');
});
it('combines URLs when baseURL and requested URL are both relative', () => {
expect(buildFullPath('/api', '/users')).toBe('/api/users');
});
});