This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import { isAvailableString, isObjectId, 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);
});
});
describe('isObjectId', () => {
test.each<[string, boolean]>([
['1', false],
['unknown', false],
['64b4a473a44c273805b25da5', true],
])('%s => %p', (input, res) => {
expect(isObjectId(input)).toBe(res);
});
});
});