0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

test: add UT cases for CustomAgents

This commit is contained in:
fix777 2024-10-21 14:28:20 +08:00
parent 4c61befd55
commit ad9edad682

View file

@ -0,0 +1,18 @@
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
import { describe, expect, test } from 'vitest';
import CustomAgents from '../src/agent';
describe('CustomAgents', () => {
test('Create a HttpProxyAgent instance if the target URL uses HTTP', () => {
const agent = new CustomAgents('http://registry.npmjs.org', 'http://127.0.0.1:7890', {}).get();
expect(agent.http).toBeInstanceOf(HttpProxyAgent);
expect(agent.https).toBeUndefined();
});
test('Create a HttpsProxyAgent instance if the target URL uses HTTPS', () => {
const agent = new CustomAgents('https://registry.npmjs.org', 'http://127.0.0.1:7890', {}).get();
expect(agent.http).toBeUndefined();
expect(agent.https).toBeInstanceOf(HttpsProxyAgent);
});
});