@@ -45,6 +45,27 @@ describe('runOpen util', () => {
45
45
} ) ;
46
46
} ) ;
47
47
48
+ it ( 'on specify URL with page inside array' , ( ) => {
49
+ return runOpen (
50
+ 'https://example.com' ,
51
+ { openPage : [ '/index.html' ] } ,
52
+ console
53
+ ) . then ( ( ) => {
54
+ expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
55
+ } ) ;
56
+ } ) ;
57
+
58
+ it ( 'on specify URL with multiple pages inside array' , ( ) => {
59
+ return runOpen (
60
+ 'https://example.com' ,
61
+ { openPage : [ '/index.html' , '/index2.html' ] } ,
62
+ console
63
+ ) . then ( ( ) => {
64
+ expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
65
+ expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
66
+ } ) ;
67
+ } ) ;
68
+
48
69
it ( 'on specify URL in Google Chrome' , ( ) => {
49
70
return runOpen (
50
71
'https://example.com' ,
@@ -118,6 +139,34 @@ describe('runOpen util', () => {
118
139
} ) ;
119
140
} ) ;
120
141
142
+ it ( 'on specify multiple absolute https URLs with pages in Google Chrome ' , ( ) => {
143
+ return runOpen (
144
+ 'https://example.com' ,
145
+ {
146
+ open : 'Google Chrome' ,
147
+ openPage : [ 'https://example2.com' , 'https://example3.com' ] ,
148
+ } ,
149
+ console
150
+ ) . then ( ( ) => {
151
+ expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
152
+ expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
153
+ } ) ;
154
+ } ) ;
155
+
156
+ it ( 'on specify one relative URL and one absolute URL with pages in Google Chrome ' , ( ) => {
157
+ return runOpen (
158
+ 'https://example.com' ,
159
+ {
160
+ open : 'Google Chrome' ,
161
+ openPage : [ '/index.html' , 'https://example2.com' ] ,
162
+ } ,
163
+ console
164
+ ) . then ( ( ) => {
165
+ expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
166
+ expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
167
+ } ) ;
168
+ } ) ;
169
+
121
170
describe ( 'should not open browser' , ( ) => {
122
171
const logMock = { warn : jest . fn ( ) } ;
123
172
@@ -132,7 +181,7 @@ describe('runOpen util', () => {
132
181
it ( 'on specify URL and log error' , ( ) => {
133
182
return runOpen ( 'https://example.com' , { } , logMock ) . then ( ( ) => {
134
183
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
135
- `"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
184
+ `"Unable to open \\"https://example.com\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
136
185
) ;
137
186
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
138
187
Array [
@@ -152,7 +201,7 @@ describe('runOpen util', () => {
152
201
logMock
153
202
) . then ( ( ) => {
154
203
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
155
- `"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
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"`
156
205
) ;
157
206
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
158
207
Array [
@@ -172,7 +221,7 @@ describe('runOpen util', () => {
172
221
logMock
173
222
) . then ( ( ) => {
174
223
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
175
- `"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
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"`
176
225
) ;
177
226
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
178
227
Array [
@@ -193,7 +242,7 @@ describe('runOpen util', () => {
193
242
logMock
194
243
) . then ( ( ) => {
195
244
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
196
- `"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
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"`
197
246
) ;
198
247
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
199
248
Array [
0 commit comments