Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D16709690 fbshipit-source-id: efa0431ab1ab0e2fc81ae4a9155d2f0a3ab9e4c5
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
|
|
import {parseFlipperPorts} from '../environmentVariables.tsx';
|
|
|
|
test('Valid port overrides are parsed correctly', () => {
|
|
const overrides = parseFlipperPorts('1111,2222');
|
|
expect(overrides).toEqual({insecure: 1111, secure: 2222});
|
|
});
|
|
|
|
test('Malformed numbers are ignored', () => {
|
|
const malformed1 = parseFlipperPorts('1111,22s22');
|
|
expect(malformed1).toBe(undefined);
|
|
|
|
const malformed2 = parseFlipperPorts('11a11,2222');
|
|
expect(malformed2).toBe(undefined);
|
|
});
|
|
|
|
test('Wrong number of values is ignored', () => {
|
|
const overrides = parseFlipperPorts('1111');
|
|
expect(overrides).toBe(undefined);
|
|
});
|
|
|
|
test('Empty values are ignored', () => {
|
|
const overrides = parseFlipperPorts('1111,');
|
|
expect(overrides).toBe(undefined);
|
|
});
|
|
|
|
test('Negative values are ignored', () => {
|
|
const overrides = parseFlipperPorts('-1111,2222');
|
|
expect(overrides).toBe(undefined);
|
|
});
|