/
axiosProxyOverridesFor.spec.ts
39 lines (29 loc) · 1.37 KB
/
axiosProxyOverridesFor.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { expect } from '@integration/testing-tools';
import axios from 'axios';
import { describe, it } from 'mocha';
import { axiosProxyOverridesFor } from '../../../../src/screenplay/abilities/proxy';
import { ProxyAgent } from '../../../../src/screenplay/abilities/proxy/ProxyAgent';
describe('axiosProxyOverridesFor', () => {
describe('when no proxy overrides are defined', () => {
it('overrides Axios built-in proxy mechanism to use env variables', () => {
const overrides = axiosProxyOverridesFor(axios.create({}).defaults);
expect(overrides.proxy).to.equal(false);
expect(overrides.httpAgent).to.be.instanceof(ProxyAgent);
expect(overrides.httpsAgent).to.be.instanceof(ProxyAgent);
});
});
describe('when proxy overrides are defined', () => {
it('creates an Axios instance that overrides Axios built-in proxy mechanism', () => {
const overrides = axiosProxyOverridesFor(axios.create({
proxy: {
protocol: 'http',
host: 'proxy.mycompany.com',
port: 9000,
}
}).defaults);
expect(overrides.proxy).to.equal(false);
expect(overrides.httpAgent).to.be.instanceof(ProxyAgent);
expect(overrides.httpsAgent).to.be.instanceof(ProxyAgent);
});
});
});