1*8c8eefe0SEvan Baconimport { wrapFetchWithProxy } from '../wrapFetchWithProxy'; 2*8c8eefe0SEvan Bacon 3*8c8eefe0SEvan Baconconst originalEnv = process.env; 4*8c8eefe0SEvan Bacon 5*8c8eefe0SEvan BaconafterAll(() => { 6*8c8eefe0SEvan Bacon process.env = originalEnv; 7*8c8eefe0SEvan Bacon}); 8*8c8eefe0SEvan Bacon 9*8c8eefe0SEvan Bacondescribe(wrapFetchWithProxy, () => { 10*8c8eefe0SEvan Bacon it(`supports normal requests`, async () => { 11*8c8eefe0SEvan Bacon delete process.env.HTTP_PROXY; 12*8c8eefe0SEvan Bacon 13*8c8eefe0SEvan Bacon const input = jest.fn(); 14*8c8eefe0SEvan Bacon const next = wrapFetchWithProxy(input); 15*8c8eefe0SEvan Bacon await next('https://example.com/', {}); 16*8c8eefe0SEvan Bacon expect(input).toBeCalledWith('https://example.com/', {}); 17*8c8eefe0SEvan Bacon }); 18*8c8eefe0SEvan Bacon it(`proxies requests`, async () => { 19*8c8eefe0SEvan Bacon process.env.HTTP_PROXY = 'http://localhost:8080'; 20*8c8eefe0SEvan Bacon const input = jest.fn(); 21*8c8eefe0SEvan Bacon const next = wrapFetchWithProxy(input); 22*8c8eefe0SEvan Bacon await next('https://example.com/', {}); 23*8c8eefe0SEvan Bacon expect(input).toBeCalledWith('https://example.com/', { 24*8c8eefe0SEvan Bacon agent: expect.objectContaining({ 25*8c8eefe0SEvan Bacon proxy: expect.objectContaining({ 26*8c8eefe0SEvan Bacon host: 'localhost', 27*8c8eefe0SEvan Bacon }), 28*8c8eefe0SEvan Bacon }), 29*8c8eefe0SEvan Bacon }); 30*8c8eefe0SEvan Bacon }); 31*8c8eefe0SEvan Bacon}); 32