axios-axios/test/specs/core/buildFullPath.spec.js
Jay fa337332b9
Update unit testing flows as part of migration to vitest (#7484)
* 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
2026-03-06 20:42:14 +02:00

35 lines
1.4 KiB
JavaScript

/* eslint-env mocha */
import buildFullPath from '../../../lib/core/buildFullPath';
describe('helpers::buildFullPath', function () {
it('should combine URLs when the requestedURL is relative', function () {
expect(buildFullPath('https://api.github.com', '/users')).toBe('https://api.github.com/users');
});
it('should not combine the URLs when the requestedURL is absolute', function () {
expect(buildFullPath('https://api.github.com', 'https://api.example.com/users')).toBe(
'https://api.example.com/users'
);
});
it('should combine the URLs when the requestedURL is absolute and allowAbsoluteUrls is false', function () {
expect(buildFullPath('https://api.github.com', 'https://api.example.com/users', false)).toBe(
'https://api.github.com/https://api.example.com/users'
);
});
it('should not combine the URLs when the requestedURL is absolute, allowAbsoluteUrls is false, and the baseURL is not configured', function () {
expect(buildFullPath(undefined, 'https://api.example.com/users', false)).toBe(
'https://api.example.com/users'
);
});
it('should not combine URLs when the baseURL is not configured', function () {
expect(buildFullPath(undefined, '/users')).toBe('/users');
});
it('should combine URLs when the baseURL and requestedURL are relative', function () {
expect(buildFullPath('/api', '/users')).toBe('/api/users');
});
});