File tree 1 file changed +96
-0
lines changed
1 file changed +96
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,102 @@ describe('historyApiFallback option', () => {
178
178
} ) ;
179
179
} ) ;
180
180
181
+ describe ( 'as object with the "verbose" option' , ( ) => {
182
+ let consoleSpy ;
183
+
184
+ beforeAll ( ( done ) => {
185
+ consoleSpy = jest . spyOn ( global . console , 'log' ) ;
186
+
187
+ server = testServer . start (
188
+ config ,
189
+ {
190
+ historyApiFallback : {
191
+ index : '/bar.html' ,
192
+ verbose : true ,
193
+ } ,
194
+ port,
195
+ } ,
196
+ done
197
+ ) ;
198
+ req = request ( server . app ) ;
199
+ } ) ;
200
+
201
+ afterAll ( ( ) => {
202
+ consoleSpy . mockRestore ( ) ;
203
+ } ) ;
204
+
205
+ it ( 'request to directory and log' , ( done ) => {
206
+ req
207
+ . get ( '/foo' )
208
+ . accept ( 'html' )
209
+ . expect ( 200 , / F o o b a r / , ( error ) => {
210
+ if ( error ) {
211
+ done ( error ) ;
212
+
213
+ return ;
214
+ }
215
+
216
+ expect ( consoleSpy ) . toHaveBeenCalledWith (
217
+ 'Rewriting' ,
218
+ 'GET' ,
219
+ '/foo' ,
220
+ 'to' ,
221
+ '/bar.html'
222
+ ) ;
223
+
224
+ done ( ) ;
225
+ } ) ;
226
+ } ) ;
227
+ } ) ;
228
+
229
+ describe ( 'as object with the "logger" option' , ( ) => {
230
+ let consoleSpy ;
231
+
232
+ beforeAll ( ( done ) => {
233
+ consoleSpy = jest . spyOn ( global . console , 'log' ) ;
234
+
235
+ server = testServer . start (
236
+ config ,
237
+ {
238
+ historyApiFallback : {
239
+ index : '/bar.html' ,
240
+ logger : consoleSpy ,
241
+ } ,
242
+ port,
243
+ } ,
244
+ done
245
+ ) ;
246
+ req = request ( server . app ) ;
247
+ } ) ;
248
+
249
+ afterAll ( ( ) => {
250
+ consoleSpy . mockRestore ( ) ;
251
+ } ) ;
252
+
253
+ it ( 'request to directory and log' , ( done ) => {
254
+ req
255
+ . get ( '/foo' )
256
+ . accept ( 'html' )
257
+ . expect ( 200 , / F o o b a r / , ( error ) => {
258
+ if ( error ) {
259
+ done ( error ) ;
260
+
261
+ return ;
262
+ }
263
+
264
+ expect ( consoleSpy ) . toHaveBeenCalledWith (
265
+ 'Rewriting' ,
266
+ 'GET' ,
267
+ '/foo' ,
268
+ 'to' ,
269
+ '/bar.html'
270
+ ) ;
271
+
272
+ done ( ) ;
273
+ } ) ;
274
+ } ) ;
275
+ } ) ;
276
+
181
277
describe ( 'in-memory files' , ( ) => {
182
278
beforeAll ( ( done ) => {
183
279
server = testServer . start (
You can’t perform that action at this time.
0 commit comments