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:
parent
4c61befd55
commit
ad9edad682
1 changed files with 18 additions and 0 deletions
18
packages/proxy/test/custom-agents.spec.ts
Normal file
18
packages/proxy/test/custom-agents.spec.ts
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue