1
1
'use strict' ;
2
2
3
- const opn = require ( 'opn ' ) ;
3
+ const open = require ( 'open ' ) ;
4
4
const runOpen = require ( '../../../lib/utils/runOpen' ) ;
5
5
6
- jest . mock ( 'opn ' ) ;
6
+ jest . mock ( 'open ' ) ;
7
7
8
8
describe ( 'runOpen util' , ( ) => {
9
9
afterEach ( ( ) => {
10
- opn . mockClear ( ) ;
10
+ open . mockClear ( ) ;
11
11
} ) ;
12
12
13
13
describe ( 'should open browser' , ( ) => {
14
14
beforeEach ( ( ) => {
15
- opn . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
15
+ open . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
16
16
} ) ;
17
17
18
18
it ( 'on specify URL' , ( ) => {
19
19
return runOpen ( 'https://example.com' , { } , console ) . then ( ( ) => {
20
- expect ( opn ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
20
+ expect ( open ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
21
21
22
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
22
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
23
23
Array [
24
24
"https://example.com",
25
25
Object {
@@ -36,11 +36,11 @@ describe('runOpen util', () => {
36
36
{ openPage : '/index.html' } ,
37
37
console
38
38
) . then ( ( ) => {
39
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
39
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
40
40
wait : false ,
41
41
} ) ;
42
42
43
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
43
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
44
44
Array [
45
45
"https://example.com/index.html",
46
46
Object {
@@ -57,11 +57,11 @@ describe('runOpen util', () => {
57
57
{ openPage : [ '/index.html' ] } ,
58
58
console
59
59
) . then ( ( ) => {
60
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
60
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
61
61
wait : false ,
62
62
} ) ;
63
63
64
- expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
64
+ expect ( open . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
65
65
} ) ;
66
66
} ) ;
67
67
@@ -71,15 +71,15 @@ describe('runOpen util', () => {
71
71
{ openPage : [ '/index.html' , '/index2.html' ] } ,
72
72
console
73
73
) . then ( ( ) => {
74
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
74
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
75
75
wait : false ,
76
76
} ) ;
77
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index2.html' , {
77
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index2.html' , {
78
78
wait : false ,
79
79
} ) ;
80
80
81
- expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
82
- expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
81
+ expect ( open . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
82
+ expect ( open . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
83
83
} ) ;
84
84
} ) ;
85
85
@@ -89,12 +89,12 @@ describe('runOpen util', () => {
89
89
{ open : 'Google Chrome' } ,
90
90
console
91
91
) . then ( ( ) => {
92
- expect ( opn ) . toBeCalledWith ( 'https://example.com' , {
92
+ expect ( open ) . toBeCalledWith ( 'https://example.com' , {
93
93
app : 'Google Chrome' ,
94
94
wait : false ,
95
95
} ) ;
96
96
97
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
97
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
98
98
Array [
99
99
"https://example.com",
100
100
Object {
@@ -112,12 +112,12 @@ describe('runOpen util', () => {
112
112
{ open : 'Google Chrome' , openPage : '/index.html' } ,
113
113
console
114
114
) . then ( ( ) => {
115
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
115
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
116
116
app : 'Google Chrome' ,
117
117
wait : false ,
118
118
} ) ;
119
119
120
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
120
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
121
121
Array [
122
122
"https://example.com/index.html",
123
123
Object {
@@ -135,12 +135,12 @@ describe('runOpen util', () => {
135
135
{ open : 'Google Chrome' , openPage : 'https://example2.com' } ,
136
136
console
137
137
) . then ( ( ) => {
138
- expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
138
+ expect ( open ) . toBeCalledWith ( 'https://example2.com' , {
139
139
app : 'Google Chrome' ,
140
140
wait : false ,
141
141
} ) ;
142
142
143
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
143
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
144
144
Array [
145
145
"https://example2.com",
146
146
Object {
@@ -158,11 +158,11 @@ describe('runOpen util', () => {
158
158
{ open : 'Google Chrome' , openPage : 'http://example2.com' } ,
159
159
console
160
160
) . then ( ( ) => {
161
- expect ( opn ) . toBeCalledWith ( 'http://example2.com' , {
161
+ expect ( open ) . toBeCalledWith ( 'http://example2.com' , {
162
162
app : 'Google Chrome' ,
163
163
wait : false ,
164
164
} ) ;
165
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
165
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
166
166
Array [
167
167
"http://example2.com",
168
168
Object {
@@ -184,16 +184,16 @@ describe('runOpen util', () => {
184
184
} ,
185
185
console
186
186
) . then ( ( ) => {
187
- expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
187
+ expect ( open ) . toBeCalledWith ( 'https://example2.com' , {
188
188
app : 'Google Chrome' ,
189
189
wait : false ,
190
190
} ) ;
191
- expect ( opn ) . toBeCalledWith ( 'https://example3.com' , {
191
+ expect ( open ) . toBeCalledWith ( 'https://example3.com' , {
192
192
app : 'Google Chrome' ,
193
193
wait : false ,
194
194
} ) ;
195
- expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
196
- expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
195
+ expect ( open . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
196
+ expect ( open . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
197
197
} ) ;
198
198
} ) ;
199
199
@@ -206,25 +206,25 @@ describe('runOpen util', () => {
206
206
} ,
207
207
console
208
208
) . then ( ( ) => {
209
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
209
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
210
210
app : 'Google Chrome' ,
211
211
wait : false ,
212
212
} ) ;
213
- expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
213
+ expect ( open ) . toBeCalledWith ( 'https://example2.com' , {
214
214
app : 'Google Chrome' ,
215
215
wait : false ,
216
216
} ) ;
217
217
218
- expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
219
- expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
218
+ expect ( open . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
219
+ expect ( open . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
220
220
} ) ;
221
221
} ) ;
222
222
223
223
describe ( 'should not open browser' , ( ) => {
224
224
const logMock = { warn : jest . fn ( ) } ;
225
225
226
226
beforeEach ( ( ) => {
227
- opn . mockImplementation ( ( ) => Promise . reject ( ) ) ;
227
+ open . mockImplementation ( ( ) => Promise . reject ( ) ) ;
228
228
} ) ;
229
229
230
230
afterEach ( ( ) => {
@@ -236,9 +236,9 @@ describe('runOpen util', () => {
236
236
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
237
237
`"Unable to open \\"https://example.com\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
238
238
) ;
239
- expect ( opn ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
239
+ expect ( open ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
240
240
241
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
241
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
242
242
Array [
243
243
"https://example.com",
244
244
Object {
@@ -258,11 +258,11 @@ describe('runOpen util', () => {
258
258
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
259
259
`"Unable to open \\"https://example.com/index.html\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
260
260
) ;
261
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
261
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
262
262
wait : false ,
263
263
} ) ;
264
264
265
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
265
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
266
266
Array [
267
267
"https://example.com/index.html",
268
268
Object {
@@ -282,12 +282,12 @@ describe('runOpen util', () => {
282
282
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
283
283
`"Unable to open \\"https://example.com\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"`
284
284
) ;
285
- expect ( opn ) . toBeCalledWith ( 'https://example.com' , {
285
+ expect ( open ) . toBeCalledWith ( 'https://example.com' , {
286
286
app : 'Google Chrome' ,
287
287
wait : false ,
288
288
} ) ;
289
289
290
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
290
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
291
291
Array [
292
292
"https://example.com",
293
293
Object {
@@ -308,12 +308,12 @@ describe('runOpen util', () => {
308
308
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
309
309
`"Unable to open \\"https://example.com/index.html\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"`
310
310
) ;
311
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
311
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
312
312
app : 'Google Chrome' ,
313
313
wait : false ,
314
314
} ) ;
315
315
316
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
316
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
317
317
Array [
318
318
"https://example.com/index.html",
319
319
Object {
@@ -334,11 +334,11 @@ describe('runOpen util', () => {
334
334
} ,
335
335
logMock
336
336
) . then ( ( ) => {
337
- expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
337
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
338
338
app : [ 'Google Chrome' , '--incognito' ] ,
339
339
} ) ;
340
340
341
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
341
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
342
342
Array [
343
343
"https://example.com/index.html",
344
344
Object {
0 commit comments