-
-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Expand file tree
/
Copy pathAppConfig.test.ts
More file actions
35 lines (24 loc) · 1.03 KB
/
AppConfig.test.ts
File metadata and controls
35 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { afterEach, describe, expect, it, jest } from '@jest/globals'
const ORIGINAL_ENV = process.env
describe('AppConfig', () => {
afterEach(() => {
process.env = ORIGINAL_ENV
jest.resetModules()
})
it('treats whitespace-padded true values as enabled', async () => {
process.env = { ...ORIGINAL_ENV, SHOW_COMMUNITY_NODES: ' true ' }
const { appConfig } = await import('./AppConfig')
expect(appConfig.showCommunityNodes).toBe(true)
})
it('keeps whitespace-padded false values disabled', async () => {
process.env = { ...ORIGINAL_ENV, SHOW_COMMUNITY_NODES: ' false ' }
const { appConfig } = await import('./AppConfig')
expect(appConfig.showCommunityNodes).toBe(false)
})
it('defaults to disabled when the env var is unset', async () => {
process.env = { ...ORIGINAL_ENV }
delete process.env.SHOW_COMMUNITY_NODES
const { appConfig } = await import('./AppConfig')
expect(appConfig.showCommunityNodes).toBe(false)
})
})