From 2785fc91aabce08522905d6ff413684745d6159a Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Thu, 15 Aug 2024 16:16:30 -0400 Subject: [PATCH] fix tests --- packages/http-client/__tests__/basics.test.ts | 24 +++++++++---------- .../http-client/__tests__/headers.test.ts | 4 ++-- packages/http-client/__tests__/proxy.test.ts | 8 +++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/http-client/__tests__/basics.test.ts b/packages/http-client/__tests__/basics.test.ts index 1e715ce9..58cf0943 100644 --- a/packages/http-client/__tests__/basics.test.ts +++ b/packages/http-client/__tests__/basics.test.ts @@ -37,7 +37,7 @@ describe('basics', () => { // "user-agent": "typed-test-client-tests" // }, // "origin": "173.95.152.44", - // "url": "https://postman-echo.com/get" + // "url": "http://postman-echo.com/get" // } it('does basic http get request', async () => { @@ -65,12 +65,12 @@ describe('basics', () => { it('does basic https get request', async () => { const res: httpm.HttpClientResponse = await _http.get( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' ) expect(res.message.statusCode).toBe(200) const body: string = await res.readBody() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') }) it('does basic http get request with default headers', async () => { @@ -125,12 +125,12 @@ describe('basics', () => { it('pipes a get request', async () => { return new Promise(async resolve => { const file = fs.createWriteStream(sampleFilePath) - ;(await _http.get('https://postman-echo.com/get')).message + ;(await _http.get('http://postman-echo.com/get')).message .pipe(file) .on('close', () => { const body: string = fs.readFileSync(sampleFilePath).toString() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') resolve() }) }) @@ -139,25 +139,25 @@ describe('basics', () => { it('does basic get request with redirects', async () => { const res: httpm.HttpClientResponse = await _http.get( `https://postman-echo.com/redirect-to?url=${encodeURIComponent( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' )}` ) expect(res.message.statusCode).toBe(200) const body: string = await res.readBody() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') }) it('does basic get request with redirects (303)', async () => { const res: httpm.HttpClientResponse = await _http.get( `https://postman-echo.com/redirect-to?url=${encodeURIComponent( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' )}&status_code=303` ) expect(res.message.statusCode).toBe(200) const body: string = await res.readBody() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') }) it('returns 404 for not found get request on redirect', async () => { @@ -178,7 +178,7 @@ describe('basics', () => { ) const res: httpm.HttpClientResponse = await http.get( `https://postman-echo.com/redirect-to?url=${encodeURIComponent( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' )}` ) expect(res.message.statusCode).toBe(302) @@ -289,11 +289,11 @@ describe('basics', () => { it('gets a json object', async () => { const jsonObj = await _http.getJson( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' ) expect(jsonObj.statusCode).toBe(200) expect(jsonObj.result).toBeDefined() - expect(jsonObj.result?.url).toBe('https://postman-echo.com/get') + expect(jsonObj.result?.url).toBe('http://postman-echo.com/get') expect(jsonObj.result?.headers[httpm.Headers.Accept]).toBe( httpm.MediaTypes.ApplicationJson ) diff --git a/packages/http-client/__tests__/headers.test.ts b/packages/http-client/__tests__/headers.test.ts index c1ca0ec3..b0a13238 100644 --- a/packages/http-client/__tests__/headers.test.ts +++ b/packages/http-client/__tests__/headers.test.ts @@ -12,7 +12,7 @@ describe('headers', () => { it('preserves existing headers on getJson', async () => { const additionalHeaders = {[httpm.Headers.Accept]: 'foo'} let jsonObj = await _http.getJson( - 'https://postman-echo.com/get', + 'http://postman-echo.com/get', additionalHeaders ) expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('foo') @@ -26,7 +26,7 @@ describe('headers', () => { [httpm.Headers.Accept]: 'baz' } } - jsonObj = await httpWithHeaders.getJson('https://postman-echo.com/get') + jsonObj = await httpWithHeaders.getJson('http://postman-echo.com/get') expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz') expect(jsonObj.headers[httpm.Headers.ContentType]).toContain( httpm.MediaTypes.ApplicationJson diff --git a/packages/http-client/__tests__/proxy.test.ts b/packages/http-client/__tests__/proxy.test.ts index c921b4bc..600c9f2d 100644 --- a/packages/http-client/__tests__/proxy.test.ts +++ b/packages/http-client/__tests__/proxy.test.ts @@ -226,12 +226,12 @@ describe('proxy', () => { process.env['https_proxy'] = _proxyUrl const httpClient = new httpm.HttpClient() const res: httpm.HttpClientResponse = await httpClient.get( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' ) expect(res.message.statusCode).toBe(200) const body: string = await res.readBody() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') expect(_proxyConnects).toEqual(['postman-echo.com:443']) }) @@ -240,12 +240,12 @@ describe('proxy', () => { process.env['no_proxy'] = 'postman-echo.com' const httpClient = new httpm.HttpClient() const res: httpm.HttpClientResponse = await httpClient.get( - 'https://postman-echo.com/get' + 'http://postman-echo.com/get' ) expect(res.message.statusCode).toBe(200) const body: string = await res.readBody() const obj = JSON.parse(body) - expect(obj.url).toBe('https://postman-echo.com/get') + expect(obj.url).toBe('http://postman-echo.com/get') expect(_proxyConnects).toHaveLength(0) })