forked from unpkg/unpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsePackageURL-test.js
More file actions
80 lines (73 loc) · 2.21 KB
/
parsePackageURL-test.js
File metadata and controls
80 lines (73 loc) · 2.21 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import parsePackageURL from '../parsePackageURL';
describe('parsePackageURL', () => {
it('parses plain packages', () => {
search: '',
query: {},
packageName: 'history',
packageVersion: '1.0.0',
filename: '/umd/history.min.js'
});
});
it('parses plain packages with a hyphen in the name', () => {
search: '',
query: {},
packageName: 'query-string',
packageVersion: '5.0.0',
filename: '/index.js'
});
});
it('parses plain packages with no version specified', () => {
expect(parsePackageURL('/query-string/index.js')).toEqual({
pathname: '/query-string/index.js',
search: '',
query: {},
packageName: 'query-string',
packageVersion: 'latest',
filename: '/index.js'
});
});
it('parses plain packages with version spec', () => {
expect(parsePackageURL('/query-string@>=4.0.0/index.js')).toEqual({
pathname: '/query-string@>=4.0.0/index.js',
search: '',
query: {},
packageName: 'query-string',
packageVersion: '>=4.0.0',
filename: '/index.js'
});
});
it('parses scoped packages', () => {
search: '',
query: {},
packageName: '@angular/router',
packageVersion: '4.3.3',
filename: '/src/index.d.ts'
});
});
it('parses package names with a period in them', () => {
expect(parsePackageURL('/index.js')).toEqual({
pathname: '/index.js',
search: '',
query: {},
packageName: 'index.js',
packageVersion: 'latest',
filename: ''
});
});
it('parses valid query parameters', () => {
expect(parsePackageURL('/history?main=browser')).toEqual({
pathname: '/history',
search: '?main=browser',
query: { main: 'browser' },
packageName: 'history',
packageVersion: 'latest',
filename: ''
});
});
});