@corrbo/react-native-dev-console
Version:
Developer menu
26 lines (25 loc) • 943 B
JavaScript
;
import extractHost from "./extractHost.js";
describe('extractHost', () => {
it('should extract host from basic url', () => {
const host = extractHost('http://something.test.com/hello');
expect(host).toEqual('something.test.com');
});
it('should extract host from url with port', () => {
const host = extractHost('http://something.test.com:123/hello');
expect(host).toEqual('something.test.com');
});
it('should extract host from ip', () => {
const host = extractHost('http://192.168.1.1/hello');
expect(host).toEqual('192.168.1.1');
});
it('should extract host from ip with port', () => {
const host = extractHost('http://192.168.1.1:123/hello');
expect(host).toEqual('192.168.1.1');
});
it('should return undefined for an invalid url', () => {
const host = extractHost('invalid-url');
expect(host).toBeUndefined();
});
});
//# sourceMappingURL=extractHost.spec.js.map