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 . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
20
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
21
21
Array [
22
22
"https://example.com",
23
23
Object {
@@ -34,7 +34,7 @@ describe('runOpen util', () => {
34
34
{ openPage : '/index.html' } ,
35
35
console
36
36
) . then ( ( ) => {
37
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
37
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
38
38
Array [
39
39
"https://example.com/index.html",
40
40
Object {
@@ -72,7 +72,7 @@ describe('runOpen util', () => {
72
72
{ open : 'Google Chrome' } ,
73
73
console
74
74
) . then ( ( ) => {
75
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
75
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
76
76
Array [
77
77
"https://example.com",
78
78
Object {
@@ -90,7 +90,7 @@ describe('runOpen util', () => {
90
90
{ open : 'Google Chrome' , openPage : '/index.html' } ,
91
91
console
92
92
) . then ( ( ) => {
93
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
93
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
94
94
Array [
95
95
"https://example.com/index.html",
96
96
Object {
@@ -171,7 +171,7 @@ describe('runOpen util', () => {
171
171
const logMock = { warn : jest . fn ( ) } ;
172
172
173
173
beforeEach ( ( ) => {
174
- opn . mockImplementation ( ( ) => Promise . reject ( ) ) ;
174
+ open . mockImplementation ( ( ) => Promise . reject ( ) ) ;
175
175
} ) ;
176
176
177
177
afterEach ( ( ) => {
@@ -183,7 +183,7 @@ describe('runOpen util', () => {
183
183
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
184
184
`"Unable to open \\"https://example.com\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
185
185
) ;
186
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
186
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
187
187
Array [
188
188
"https://example.com",
189
189
Object {
@@ -203,7 +203,7 @@ describe('runOpen util', () => {
203
203
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
204
204
`"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"`
205
205
) ;
206
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
206
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
207
207
Array [
208
208
"https://example.com/index.html",
209
209
Object {
@@ -223,7 +223,7 @@ describe('runOpen util', () => {
223
223
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
224
224
`"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"`
225
225
) ;
226
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
226
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
227
227
Array [
228
228
"https://example.com",
229
229
Object {
@@ -244,7 +244,7 @@ describe('runOpen util', () => {
244
244
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
245
245
`"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"`
246
246
) ;
247
- expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
247
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
248
248
Array [
249
249
"https://example.com/index.html",
250
250
Object {
0 commit comments