fork of hey-api/openapi-ts because I need some additional things
1import { parseUrl } from '../url';
2
3describe('parseUrl', () => {
4 it.each([
5 { host: '', path: '', port: '', protocol: '', value: '' },
6 { host: '', path: '', port: '', protocol: '', value: '/' },
7 { host: 'foo.com', path: '', port: '', protocol: '', value: 'foo.com' },
8 { host: 'foo.com', path: '', port: '', protocol: '', value: 'foo.com/' },
9 {
10 host: 'foo.com',
11 path: '/bar',
12 port: '',
13 protocol: '',
14 value: 'foo.com/bar',
15 },
16 {
17 host: 'www.foo.com',
18 path: '/bar',
19 port: '',
20 protocol: '',
21 value: 'www.foo.com/bar',
22 },
23 {
24 host: 'www.foo.com',
25 path: '/bar',
26 port: '',
27 protocol: 'https',
28 value: 'https://www.foo.com/bar',
29 },
30 {
31 host: 'www.foo.com',
32 path: '/bar',
33 port: '',
34 protocol: 'custom',
35 value: 'custom://www.foo.com/bar',
36 },
37 {
38 host: 'foo.com',
39 path: '/bar',
40 port: '',
41 protocol: 'ws',
42 value: 'ws://foo.com/bar',
43 },
44 {
45 host: 'foo.com',
46 path: '/bar',
47 port: '',
48 protocol: '',
49 value: '//foo.com/bar?ignore',
50 },
51 { host: 'foo.com', path: '', port: '', protocol: '', value: '//foo.com' },
52 { host: '', path: '', port: '', protocol: 'https', value: 'https://' },
53 { host: '', path: '/bar', port: '', protocol: '', value: '/bar' },
54 {
55 host: 'localhost',
56 path: '',
57 port: '3025',
58 protocol: 'http',
59 value: 'http://localhost:3025',
60 },
61 {
62 host: 'localhost',
63 path: '',
64 port: '',
65 protocol: 'https',
66 value: 'https://localhost',
67 },
68 { host: '', path: '/v1/foo', port: '', protocol: '', value: '/v1/foo' },
69 {
70 host: '10.0.81.36',
71 path: '/v1',
72 port: '',
73 protocol: 'http',
74 value: 'http://10.0.81.36/v1',
75 },
76 {
77 host: '{id}.foo.com',
78 path: '/v1',
79 port: '{port}',
80 protocol: 'https',
81 value: 'https://{id}.foo.com:{port}/v1',
82 },
83 { host: '', path: '', port: '', protocol: '', value: './foo.json' },
84 { host: '', path: '', port: '', protocol: '', value: '../../foo.json' },
85 { host: '', path: '', port: '', protocol: '', value: 'D://\\foo.json' },
86 ])('$value', ({ host, path, port, protocol, value }) => {
87 expect(parseUrl(value)).toEqual({
88 host,
89 path,
90 port,
91 protocol,
92 });
93 });
94});