-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(utils): add coverage for
getEnvironmentType
- Loading branch information
1 parent
9b77c9d
commit 5bc5d97
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/utils/src/lib/reports/environment-type.unit.test.ts
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,30 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { getEnvironmentType } from './environment-type'; | ||
|
||
describe('getEnvironmentType', () => { | ||
it.each([ | ||
['TERM_PROGRAM', 'vscode', 'vscode'], | ||
['GITHUB_ACTIONS', 'true', 'github'], | ||
['GITLAB_CI', 'true', 'gitlab'], | ||
])( | ||
'should return the environment type when %s environment variable is set', | ||
(envVarName, envVarValue, expected) => { | ||
// reset potentially interfering environment variables | ||
vi.stubEnv('TERM_PROGRAM', ''); | ||
vi.stubEnv('GITHUB_ACTIONS', 'false'); | ||
vi.stubEnv('GITLAB_CI', 'false'); | ||
|
||
vi.stubEnv(envVarName, envVarValue); | ||
expect(getEnvironmentType()).toBe(expected); | ||
}, | ||
); | ||
|
||
it('should return "other" when no expected environment variables are set', () => { | ||
// reset potentially interfering environment variables | ||
vi.stubEnv('TERM_PROGRAM', ''); | ||
vi.stubEnv('GITHUB_ACTIONS', 'false'); | ||
vi.stubEnv('GITLAB_CI', 'false'); | ||
|
||
expect(getEnvironmentType()).toBe('other'); | ||
}); | ||
}); |