mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-07-10 01:57:16 +03:00
feat: Introduce fe modular build system
This commit is contained in:
40
fe-app-podkop/src/validators/tests/validateUrl.test.js
Normal file
40
fe-app-podkop/src/validators/tests/validateUrl.test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { validateUrl } from '../validateUrl';
|
||||
|
||||
const validUrls = [
|
||||
['Simple HTTP', 'http://example.com'],
|
||||
['Simple HTTPS', 'https://example.com'],
|
||||
['With path', 'https://example.com/path/to/page'],
|
||||
['With query', 'https://example.com/?q=test'],
|
||||
['With port', 'http://example.com:8080'],
|
||||
['With subdomain', 'https://sub.example.com'],
|
||||
];
|
||||
|
||||
const invalidUrls = [
|
||||
['Invalid format', 'not a url'],
|
||||
['Missing protocol', 'example.com'],
|
||||
['Unsupported protocol (ftp)', 'ftp://example.com'],
|
||||
['Unsupported protocol (ws)', 'ws://example.com'],
|
||||
['Empty string', ''],
|
||||
];
|
||||
|
||||
describe('validateUrl', () => {
|
||||
describe.each(validUrls)('Valid URL: %s', (_desc, url) => {
|
||||
it(`returns valid=true for "${url}"`, () => {
|
||||
const res = validateUrl(url);
|
||||
expect(res.valid).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each(invalidUrls)('Invalid URL: %s', (_desc, url) => {
|
||||
it(`returns valid=false for "${url}"`, () => {
|
||||
const res = validateUrl(url);
|
||||
expect(res.valid).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows custom protocol list (ftp)', () => {
|
||||
const res = validateUrl('ftp://example.com', ['ftp:']);
|
||||
expect(res.valid).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user