-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): update update-notifier to 7.0.0 #1544
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import { HttpsProxyAgent } from 'https-proxy-agent'; | ||
import { SocksProxyAgent } from 'socks-proxy-agent'; | ||
|
||
import { createProxyAgent } from '../../../src/lib/http/proxy-agent'; | ||
|
||
// Reference for testing with env variables within a test: https://github.com/vuejs/vue-test-utils/issues/193 | ||
|
||
describe( 'validate CreateProxyAgent', () => { | ||
let env; | ||
|
||
beforeAll( () => { | ||
env = { ...process.env }; | ||
} ); | ||
|
||
beforeEach( () => { | ||
// Clear all applicable environment variables before running test so each test starts "clean" | ||
// using beforeEach instead of afterEach in case the client running tests has env variables set before the first test is run | ||
|
@@ -19,6 +27,10 @@ describe( 'validate CreateProxyAgent', () => { | |
} | ||
} ); | ||
|
||
afterAll( () => { | ||
process.env = { ...env }; | ||
} ); | ||
|
||
// Tests checking for null results | ||
it.each( [ | ||
{ | ||
|
@@ -90,11 +102,7 @@ describe( 'validate CreateProxyAgent', () => { | |
urlToHit: 'https://wpAPI.org/api', | ||
}, | ||
] )( 'should return null with %o', async ( { envVars, urlToHit } ) => { | ||
setEnvironmentVariabeles( envVars ); | ||
// We have to dynamically import the module so we can set environment variables above | ||
// All tests must be async to support this dynamic import, otherwise the modified env variables are not picked up | ||
const createProxyAgent = ( await import( '../../../src/lib/http/proxy-agent' ) ) | ||
.createProxyAgent; | ||
Comment on lines
-93
to
-97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It magically works :-) I found no code in |
||
setEnvironmentVariables( envVars ); | ||
const agent = createProxyAgent( urlToHit ); | ||
expect( agent ).toBeNull(); | ||
} ); | ||
|
@@ -167,17 +175,15 @@ describe( 'validate CreateProxyAgent', () => { | |
expectedClass: HttpsProxyAgent, | ||
}, | ||
] )( 'should return proxy with %o', async ( { envVars, urlToHit, expectedClass } ) => { | ||
setEnvironmentVariabeles( envVars ); | ||
const createProxyAgent = ( await import( '../../../src/lib/http/proxy-agent' ) ) | ||
.createProxyAgent; | ||
setEnvironmentVariables( envVars ); | ||
const agent = createProxyAgent( urlToHit ); | ||
expect( agent ).not.toBeNull(); | ||
expect( agent ).toBeInstanceOf( expectedClass ); | ||
} ); | ||
|
||
// Helper function to set environment variables based on passed in object | ||
// envVars of the form: [ { VAR: 'VALUE' }, { VAR1: 'VALUE1' }, ... ] | ||
function setEnvironmentVariabeles( envVars ) { | ||
function setEnvironmentVariables( envVars ) { | ||
for ( const index in envVars ) { | ||
for ( const key in envVars[ index ] ) { | ||
process.env[ key ] = envVars[ index ][ key ]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is unnecessary, but I prefer restoring things to their original state.