mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
779 B
TypeScript
32 lines
779 B
TypeScript
import { isAvailableString, isUrl } from '../string-helper';
|
|
|
|
describe('string-helper', () => {
|
|
describe('isAvailableString', () => {
|
|
test.each<[any, boolean]>([
|
|
['any string', true],
|
|
['', false],
|
|
[1, false],
|
|
[() => {}, false],
|
|
[{}, false],
|
|
[[], false],
|
|
[undefined, false],
|
|
[null, false],
|
|
])('%p => %p', (url, res) => {
|
|
expect(isAvailableString(url)).toBe(res);
|
|
});
|
|
});
|
|
|
|
describe('isUrl', () => {
|
|
test.each<[string, boolean]>([
|
|
['http://baidu.com', true],
|
|
['https://baidu.com', true],
|
|
['ws://baidu.com', true],
|
|
['wss://baidu.com', true],
|
|
['baidu.com', false],
|
|
['baidu', false],
|
|
])('%s => %p', (url, res) => {
|
|
expect(isUrl(url)).toBe(res);
|
|
});
|
|
});
|
|
});
|