@@ -47,11 +47,10 @@ t.test('returns error for non-https and non-file url', async (t) => {
47
47
openerOpts = null
48
48
OUTPUT . length = 0
49
49
} )
50
- t . rejects ( openUrl ( npm , 'ftp://www.npmjs.com' , 'npm home' ) , / I n v a l i d U R L / , 'got the correct error' )
50
+ await t . rejects ( openUrl ( npm , 'ftp://www.npmjs.com' , 'npm home' ) , / I n v a l i d U R L / , 'got the correct error' )
51
51
t . equal ( openerUrl , null , 'did not open' )
52
52
t . same ( openerOpts , null , 'did not open' )
53
53
t . same ( OUTPUT , [ ] , 'printed no output' )
54
- t . end ( )
55
54
} )
56
55
57
56
t . test ( 'returns error for non-parseable url' , async ( t ) => {
@@ -60,11 +59,22 @@ t.test('returns error for non-parseable url', async (t) => {
60
59
openerOpts = null
61
60
OUTPUT . length = 0
62
61
} )
63
- t . rejects ( openUrl ( npm , 'git+ssh://user@host:repo.git' , 'npm home' ) , / I n v a l i d U R L / , 'got the correct error' )
62
+ await t . rejects ( openUrl ( npm , 'git+ssh://user@host:repo.git' , 'npm home' ) , / I n v a l i d U R L / , 'got the correct error' )
64
63
t . equal ( openerUrl , null , 'did not open' )
65
64
t . same ( openerOpts , null , 'did not open' )
66
65
t . same ( OUTPUT , [ ] , 'printed no output' )
67
- t . end ( )
66
+ } )
67
+
68
+ t . test ( 'encodes non-URL-safe characters in url provided' , async ( t ) => {
69
+ t . teardown ( ( ) => {
70
+ openerUrl = null
71
+ openerOpts = null
72
+ OUTPUT . length = 0
73
+ } )
74
+ await openUrl ( npm , 'https://www.npmjs.com/|cat' , 'npm home' )
75
+ t . equal ( openerUrl , 'https://www.npmjs.com/%7Ccat' , 'opened the encoded url' )
76
+ t . same ( openerOpts , { command : null } , 'passed command as null (the default)' )
77
+ t . same ( OUTPUT , [ ] , 'printed no output' )
68
78
} )
69
79
70
80
t . test ( 'opens a url with the given browser' , async ( t ) => {
@@ -79,7 +89,6 @@ t.test('opens a url with the given browser', async (t) => {
79
89
t . equal ( openerUrl , 'https://www.npmjs.com' , 'opened the given url' )
80
90
t . same ( openerOpts , { command : 'chrome' } , 'passed the given browser as command' )
81
91
t . same ( OUTPUT , [ ] , 'printed no output' )
82
- t . end ( )
83
92
} )
84
93
85
94
t . test ( 'prints where to go when browser is disabled' , async ( t ) => {
@@ -96,7 +105,6 @@ t.test('prints where to go when browser is disabled', async (t) => {
96
105
t . equal ( OUTPUT . length , 1 , 'got one logged message' )
97
106
t . equal ( OUTPUT [ 0 ] . length , 1 , 'logged message had one value' )
98
107
t . matchSnapshot ( OUTPUT [ 0 ] [ 0 ] , 'printed expected message' )
99
- t . end ( )
100
108
} )
101
109
102
110
t . test ( 'prints where to go when browser is disabled and json is enabled' , async ( t ) => {
@@ -115,7 +123,6 @@ t.test('prints where to go when browser is disabled and json is enabled', async
115
123
t . equal ( OUTPUT . length , 1 , 'got one logged message' )
116
124
t . equal ( OUTPUT [ 0 ] . length , 1 , 'logged message had one value' )
117
125
t . matchSnapshot ( OUTPUT [ 0 ] [ 0 ] , 'printed expected message' )
118
- t . end ( )
119
126
} )
120
127
121
128
t . test ( 'prints where to go when given browser does not exist' , async ( t ) => {
@@ -133,7 +140,6 @@ t.test('prints where to go when given browser does not exist', async (t) => {
133
140
t . equal ( OUTPUT . length , 1 , 'got one logged message' )
134
141
t . equal ( OUTPUT [ 0 ] . length , 1 , 'logged message had one value' )
135
142
t . matchSnapshot ( OUTPUT [ 0 ] [ 0 ] , 'printed expected message' )
136
- t . end ( )
137
143
} )
138
144
139
145
t . test ( 'handles unknown opener error' , async ( t ) => {
@@ -146,5 +152,4 @@ t.test('handles unknown opener error', async (t) => {
146
152
npm . config . set ( 'browser' , true )
147
153
} )
148
154
t . rejects ( openUrl ( npm , 'https://www.npmjs.com' , 'npm home' ) , 'failed' , 'got the correct error' )
149
- t . end ( )
150
155
} )
0 commit comments