Validate port numbers better
This commit is contained in:
parent
9806d6c12f
commit
2ada552220
4 changed files with 37 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import { isChannel, isValidNick, isValidChannel, isValidUsername } from '..';
|
||||
import { isChannel, isValidNick, isValidChannel, isValidUsername, isInt } from '..';
|
||||
import linkify from '../linkify';
|
||||
|
||||
describe('isChannel()', () => {
|
||||
|
@ -76,6 +76,22 @@ describe('isValidUsername()', () => {
|
|||
));
|
||||
});
|
||||
|
||||
describe('isInt()', () => {
|
||||
it('validates integers', () => {
|
||||
expect(isInt('0')).toBe(true);
|
||||
expect(isInt('1337')).toBe(true);
|
||||
expect(isInt('0', 0, 65535)).toBe(true);
|
||||
expect(isInt('0', 1, 65535)).toBe(false);
|
||||
expect(isInt('1', 1, 65535)).toBe(true);
|
||||
expect(isInt('65535', 1, 65535)).toBe(true);
|
||||
expect(isInt('00065535', 1, 65535)).toBe(true);
|
||||
expect(isInt('65536', 1, 65535)).toBe(false);
|
||||
expect(isInt('1cake', 1, 65535)).toBe(false);
|
||||
expect(isInt('cake1', 1, 65535)).toBe(false);
|
||||
expect(isInt('', 1, 65535)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('linkify()', () => {
|
||||
const proto = href => (href.indexOf('http') !== 0 ? `http://${href}` : href);
|
||||
const linkTo = href => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue