generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry pick test DWN URL from envvar commits from @finn-tbd PR #161
Signed-off-by: Frank Hinek <[email protected]>
- Loading branch information
1 parent
a9610d7
commit fef91b2
Showing
14 changed files
with
94 additions
and
33 deletions.
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
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
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,24 @@ | ||
declare const __karma__: { config?: { testDwnUrl?: string; } }; | ||
|
||
const DEFAULT_TEST_DWN_URL = 'https://dwn.tbddev.org/dwn0'; | ||
|
||
function getTestDwnUrl(): string { | ||
// Check to see if we're running in a Karma browser test environment. | ||
const browserTestEnvironment = typeof __karma__ !== 'undefined' && __karma__?.config?.testDwnUrl !== undefined; | ||
|
||
// Check to see if we're running in a Node environment. | ||
const nodeTestEnvironment = process && process?.env !== undefined; | ||
|
||
// Attempt to use DWN URL defined in Karma config, if running a browser test. | ||
// Otherwise, attempt to use the Node environment variable. | ||
const envTestDwnUrl = (browserTestEnvironment) | ||
? __karma__.config!.testDwnUrl | ||
: (nodeTestEnvironment) | ||
? process.env.TEST_DWN_URL | ||
: undefined; | ||
|
||
// If defined, return the test environment DWN URL. Otherwise, return the default. | ||
return envTestDwnUrl || DEFAULT_TEST_DWN_URL; | ||
} | ||
|
||
export const testDwnUrl = getTestDwnUrl(); |
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
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
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,24 @@ | ||
declare const __karma__: { config?: { testDwnUrl?: string; } }; | ||
|
||
const DEFAULT_TEST_DWN_URL = 'https://dwn.tbddev.org/dwn0'; | ||
|
||
function getTestDwnUrl(): string { | ||
// Check to see if we're running in a Karma browser test environment. | ||
const browserTestEnvironment = typeof __karma__ !== 'undefined' && __karma__?.config?.testDwnUrl !== undefined; | ||
|
||
// Check to see if we're running in a Node environment. | ||
const nodeTestEnvironment = process && process?.env !== undefined; | ||
|
||
// Attempt to use DWN URL defined in Karma config, if running a browser test. | ||
// Otherwise, attempt to use the Node environment variable. | ||
const envTestDwnUrl = (browserTestEnvironment) | ||
? __karma__.config!.testDwnUrl | ||
: (nodeTestEnvironment) | ||
? process.env.TEST_DWN_URL | ||
: undefined; | ||
|
||
// If defined, return the test environment DWN URL. Otherwise, return the default. | ||
return envTestDwnUrl || DEFAULT_TEST_DWN_URL; | ||
} | ||
|
||
export const testDwnUrl = getTestDwnUrl(); |
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
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
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
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
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
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
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
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