forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.test.ts
43 lines (36 loc) · 1.11 KB
/
env.test.ts
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
36
37
38
39
40
41
42
43
import { isDevelopmentEnv, isProductionEnv, isStagingEnv, isTestEnv } from './env'
describe('env', () => {
const ENV = process.env
afterEach(() => {
process.env = ENV
})
function setEnv(env: Record<string, unknown>) {
process.env = {
PUBLIC_URL: 'http://example.com',
NODE_ENV: 'development',
...env,
}
}
it('isDevelopmentEnv is true if NODE_ENV=development', () => {
setEnv({ NODE_ENV: 'development' })
expect(isDevelopmentEnv()).toBe(true)
})
it('isTestEnv is true if NODE_ENV=test', () => {
setEnv({ NODE_ENV: 'test' })
expect(isTestEnv()).toBe(true)
})
it('isStagingEnv is true REACT_APP_STAGING=1', () => {
setEnv({ REACT_APP_STAGING: 1 })
expect(isStagingEnv()).toBe(true)
})
describe('isProductionEnv', () => {
it('is true if NODE_ENV=production', () => {
setEnv({ NODE_ENV: 'production' })
expect(isProductionEnv()).toBe(true)
})
it('is false if NODE_ENV=production and REACT_APP_STAGING=1', () => {
setEnv({ NODE_ENV: 'production', REACT_APP_STAGING: 1 })
expect(isProductionEnv()).toBe(false)
})
})
})