From 27da30f94ff08f58a47632309c16f051a8dbb961 Mon Sep 17 00:00:00 2001 From: Dimitri DO BAIRRO Date: Tue, 26 Mar 2024 10:53:15 +0100 Subject: [PATCH] tests: test updated --- __tests__/unit/__snapshots__/shifter.ts.snap | 9 --------- __tests__/unit/shifter.ts | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 __tests__/unit/__snapshots__/shifter.ts.snap diff --git a/__tests__/unit/__snapshots__/shifter.ts.snap b/__tests__/unit/__snapshots__/shifter.ts.snap deleted file mode 100644 index 1ef7027..0000000 --- a/__tests__/unit/__snapshots__/shifter.ts.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Shifter #setIp when given one or more specific countries to target creates a properly formed proxy agent 1`] = `"https://50.14.52.12:12356/"`; - -exports[`Shifter #setIp when given one or more specific countries to target creates a properly formed proxy agent 2`] = `"http://50.14.52.12:12356/"`; - -exports[`Shifter #setIp when not given any specific country to target creates a properly formed proxy agent 1`] = `"https://50.14.52.12:12356/"`; - -exports[`Shifter #setIp when not given any specific country to target creates a properly formed proxy agent 2`] = `"http://50.14.52.12:12356/"`; diff --git a/__tests__/unit/shifter.ts b/__tests__/unit/shifter.ts index f35d1f5..754e5ee 100644 --- a/__tests__/unit/shifter.ts +++ b/__tests__/unit/shifter.ts @@ -62,8 +62,8 @@ describe('Shifter', () => { it('creates a properly formed proxy agent', () => { const agent: Shifter = shifter.setIp(); - expect(agent.axios.defaults.httpsAgent.proxy).toMatchSnapshot(); - expect(agent.axios.defaults.httpAgent.proxy).toMatchSnapshot(); + expect(agent.axios.defaults.httpsAgent.proxy.toString()).toMatch(new RegExp(`https://${proxy.host}:[0-9]+`)); + expect(agent.axios.defaults.httpAgent.proxy.toString()).toMatch(new RegExp(`http://${proxy.host}:[0-9]+`)); }); it('creates a proxy agent having a random port among the given mapping', () => { @@ -78,8 +78,8 @@ describe('Shifter', () => { it('creates a properly formed proxy agent', () => { const agent: Shifter = shifter.setIp(); - expect(agent.axios.defaults.httpsAgent.proxy).toMatchSnapshot(); - expect(agent.axios.defaults.httpAgent.proxy).toMatchSnapshot(); + expect(agent.axios.defaults.httpsAgent.proxy.toString()).toMatch(new RegExp(`https://${proxy.host}:[0-9]+`)); + expect(agent.axios.defaults.httpAgent.proxy.toString()).toMatch(new RegExp(`http://${proxy.host}:[0-9]+`)); }); it('create a proxy agent having a port matching one of the options in the mapping', () => {