-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Increase robustness of
FUEL_NETWORK_URL
config (#1379)
* test: add testcases for wallet config network url export * chore: changeset * feat: increase robustness of fuel network url config
- Loading branch information
1 parent
ad72725
commit 0d12dc0
Showing
3 changed files
with
58 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
describe('Configs', () => { | ||
it('exports FUEL_NETWORK_URL', async () => { | ||
const configs = await import('./configs'); | ||
expect(configs.FUEL_NETWORK_URL).toBe('http://127.0.0.1:4000/graphql'); | ||
}); | ||
}); | ||
|
||
describe('Configs - undefined process', () => { | ||
const originalProcess = process; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
|
||
// @ts-expect-error - test to assert undefined process | ||
// eslint-disable-next-line no-global-assign | ||
process = undefined; | ||
}); | ||
|
||
afterEach(() => { | ||
// eslint-disable-next-line no-global-assign | ||
process = originalProcess; | ||
}); | ||
|
||
it('exports FUEL_NETWORK_URL with undefined process', async () => { | ||
expect(typeof process).toBe('undefined'); | ||
expect(process).toBeUndefined(); | ||
|
||
const configs = await import('./configs'); | ||
|
||
expect(configs.FUEL_NETWORK_URL).toBe('http://127.0.0.1:4000/graphql'); | ||
}); | ||
}); | ||
|
||
describe('Configs - overridden env', () => { | ||
const originalEnv = process.env; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
|
||
process.env = { ...originalEnv, FUEL_NETWORK_URL: 'some-other-network-url' }; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
it('exports FUEL_NETWORK_URL with overridden env', async () => { | ||
const configs = await import('./configs'); | ||
|
||
expect(configs.FUEL_NETWORK_URL).toBe('some-other-network-url'); | ||
}); | ||
}); |
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 +1,4 @@ | ||
export const FUEL_NETWORK_URL = process?.env?.FUEL_NETWORK_URL || 'http://127.0.0.1:4000/graphql'; | ||
export const FUEL_NETWORK_URL = | ||
typeof process !== 'undefined' | ||
? process?.env?.FUEL_NETWORK_URL || 'http://127.0.0.1:4000/graphql' | ||
: 'http://127.0.0.1:4000/graphql'; |