1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00
unleash.unleash/src/lib/util/env.test.ts

26 lines
1.1 KiB
TypeScript
Raw Normal View History

import { parseEnvVarBoolean, parseEnvVarNumber } from './env';
test('parseEnvVarNumber', () => {
expect(parseEnvVarNumber('', 1)).toEqual(1);
expect(parseEnvVarNumber('', 2)).toEqual(2);
expect(parseEnvVarNumber(' ', 1)).toEqual(1);
expect(parseEnvVarNumber('a', 1)).toEqual(1);
expect(parseEnvVarNumber('1', 1)).toEqual(1);
expect(parseEnvVarNumber('2', 1)).toEqual(2);
expect(parseEnvVarNumber('2e2', 1)).toEqual(2);
expect(parseEnvVarNumber('-1', 1)).toEqual(-1);
});
test('parseEnvVarBoolean', () => {
expect(parseEnvVarBoolean('', true)).toEqual(true);
expect(parseEnvVarBoolean('', false)).toEqual(false);
expect(parseEnvVarBoolean(' ', false)).toEqual(false);
expect(parseEnvVarBoolean('1', false)).toEqual(true);
expect(parseEnvVarBoolean('2', false)).toEqual(false);
expect(parseEnvVarBoolean('t', false)).toEqual(true);
expect(parseEnvVarBoolean('f', false)).toEqual(false);
expect(parseEnvVarBoolean('true', false)).toEqual(true);
expect(parseEnvVarBoolean('false', false)).toEqual(false);
expect(parseEnvVarBoolean('test', false)).toEqual(false);
});