-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_test.ts
34 lines (31 loc) · 1.53 KB
/
mod_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { equal } from 'jsr:@std/[email protected]';
import shurley from './mod.ts';
Deno.test('that .parse() works', () => {
const tests: { url: string; expected: string }[] = [
{ url: 'example.com', expected: 'https://example.com' },
{ url: '/example.com', expected: 'https://example.com' },
{ url: '//example.com', expected: 'https://example.com' },
{ url: '///example.com', expected: 'https://example.com' },
{
url: 'user:[email protected]',
expected: 'https://user:[email protected]',
},
{ url: 'http:/example.com', expected: 'https://example.com' },
{ url: 'http:/example.com', expected: 'https://example.com' },
{ url: 'ftp:/example.com', expected: 'https://example.com' },
{ url: 'ftp://example.com', expected: 'https://example.com' },
{ url: 'httpss:/example.com', expected: 'https://example.com' },
{ url: 'httpss:///example.com', expected: 'https://example.com' },
{ url: 'https://example.com ', expected: 'https://example.com' },
{ url: ' https://example.com ', expected: 'https://example.com' },
{ url: 'http://example.com', expected: 'http://example.com' },
{ url: 'https://example.com', expected: 'https://example.com' },
{ url: 'https://example.com/', expected: 'https://example.com/' },
{ url: 'https://example.com/something', expected: 'https://example.com/something' },
{ url: 'git:example.com', expected: 'https://git:example.com' },
];
for (const test of tests) {
const parsedUrl = shurley.parse(test.url);
equal(parsedUrl, test.expected);
}
});