2022-08-19 08:09:44 +02:00
|
|
|
import {
|
|
|
|
parseEnvVarBoolean,
|
|
|
|
parseEnvVarNumber,
|
|
|
|
parseEnvVarStrings,
|
|
|
|
} from './parseEnvVar';
|
2022-06-02 10:44:45 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2022-08-19 08:09:44 +02:00
|
|
|
|
|
|
|
test('parseEnvVarStringList', () => {
|
2022-08-26 09:09:48 +02:00
|
|
|
expect(parseEnvVarStrings(undefined, [])).toEqual([]);
|
|
|
|
expect(parseEnvVarStrings(undefined, ['a'])).toEqual(['a']);
|
|
|
|
expect(parseEnvVarStrings('', ['a'])).toEqual([]);
|
2022-08-19 08:09:44 +02:00
|
|
|
expect(parseEnvVarStrings('', [])).toEqual([]);
|
|
|
|
expect(parseEnvVarStrings(' ', [])).toEqual([]);
|
|
|
|
expect(parseEnvVarStrings('a', ['*'])).toEqual(['a']);
|
|
|
|
expect(parseEnvVarStrings('a,b,c', [])).toEqual(['a', 'b', 'c']);
|
|
|
|
expect(parseEnvVarStrings('a,b,c', [])).toEqual(['a', 'b', 'c']);
|
|
|
|
expect(parseEnvVarStrings(' a,,,b, c , ,', [])).toEqual(['a', 'b', 'c']);
|
|
|
|
});
|