2021-03-22 12:39:24 +01:00
|
|
|
import { getDefaultConfig, overrideWithEnv } from '../src/shared/config'
|
2020-12-08 11:42:51 +01:00
|
|
|
|
2021-02-22 20:02:02 +01:00
|
|
|
test('overrideWithEnv 1', () => {
|
2020-12-08 11:42:51 +01:00
|
|
|
const defaultConfig = getDefaultConfig()
|
|
|
|
const env = {
|
|
|
|
DISABLE_WEB: 'false',
|
|
|
|
WEB_PORT: '3008',
|
|
|
|
WEB_HOSTNAME: '0.0.0.0',
|
|
|
|
BASE_DIR: undefined,
|
|
|
|
}
|
|
|
|
const config = overrideWithEnv(getDefaultConfig(), env)
|
|
|
|
|
|
|
|
expect(config.DISABLE_WEB).toEqual(false)
|
|
|
|
expect(config.WEB_PORT).toEqual(3008)
|
|
|
|
expect(config.WEB_HOSTNAME).toEqual('0.0.0.0')
|
|
|
|
expect(config.BASE_DIR).toEqual(defaultConfig.BASE_DIR)
|
|
|
|
})
|
|
|
|
|
2021-02-22 20:02:02 +01:00
|
|
|
test('overrideWithEnv 2', () => {
|
2020-12-08 11:42:51 +01:00
|
|
|
const defaultConfig = getDefaultConfig()
|
|
|
|
const env = {
|
|
|
|
DISABLE_WEB: '1',
|
|
|
|
WEB_PORT: '3008.12',
|
|
|
|
}
|
|
|
|
const config = overrideWithEnv(getDefaultConfig(), env)
|
|
|
|
|
|
|
|
expect(config.DISABLE_WEB).toEqual(true)
|
|
|
|
expect(config.WEB_PORT).toEqual(3008.12)
|
|
|
|
})
|