@@ -326,4 +326,132 @@ describe('staticTheme', function () {
326
326
} ) ;
327
327
} ) ;
328
328
} ) ;
329
+
330
+ describe ( 'fallthrough behavior' , function ( ) {
331
+ it ( 'should set fallthrough to true for /robots.txt' , function ( done ) {
332
+ req . path = '/robots.txt' ;
333
+
334
+ staticTheme ( ) ( req , res , function next ( ) {
335
+ // Specifically gets called twice
336
+ activeThemeStub . calledTwice . should . be . true ( ) ;
337
+ expressStaticStub . called . should . be . true ( ) ;
338
+
339
+ // Check that express static gets called with correct options
340
+ should . exist ( expressStaticStub . firstCall . args ) ;
341
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
342
+
343
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
344
+ options . should . be . an . Object ( ) ;
345
+ options . should . have . property ( 'maxAge' ) ;
346
+ options . should . have . property ( 'fallthrough' , true ) ;
347
+
348
+ done ( ) ;
349
+ } ) ;
350
+ } ) ;
351
+
352
+ it ( 'should set fallthrough to true for /sitemap.xml' , function ( done ) {
353
+ req . path = '/sitemap.xml' ;
354
+
355
+ staticTheme ( ) ( req , res , function next ( ) {
356
+ // Specifically gets called twice
357
+ activeThemeStub . calledTwice . should . be . true ( ) ;
358
+ expressStaticStub . called . should . be . true ( ) ;
359
+
360
+ // Check that express static gets called with correct options
361
+ should . exist ( expressStaticStub . firstCall . args ) ;
362
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
363
+
364
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
365
+ options . should . be . an . Object ( ) ;
366
+ options . should . have . property ( 'maxAge' ) ;
367
+ options . should . have . property ( 'fallthrough' , true ) ;
368
+
369
+ done ( ) ;
370
+ } ) ;
371
+ } ) ;
372
+
373
+ it ( 'should set fallthrough to true for /sitemap-posts.xml' , function ( done ) {
374
+ req . path = '/sitemap-posts.xml' ;
375
+
376
+ staticTheme ( ) ( req , res , function next ( ) {
377
+ // Specifically gets called twice
378
+ activeThemeStub . calledTwice . should . be . true ( ) ;
379
+ expressStaticStub . called . should . be . true ( ) ;
380
+
381
+ // Check that express static gets called with correct options
382
+ should . exist ( expressStaticStub . firstCall . args ) ;
383
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
384
+
385
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
386
+ options . should . be . an . Object ( ) ;
387
+ options . should . have . property ( 'maxAge' ) ;
388
+ options . should . have . property ( 'fallthrough' , true ) ;
389
+
390
+ done ( ) ;
391
+ } ) ;
392
+ } ) ;
393
+
394
+ it ( 'should set fallthrough to false for other static files' , function ( done ) {
395
+ req . path = '/style.css' ;
396
+
397
+ staticTheme ( ) ( req , res , function next ( ) {
398
+ // Specifically gets called twice
399
+ activeThemeStub . calledTwice . should . be . true ( ) ;
400
+ expressStaticStub . called . should . be . true ( ) ;
401
+
402
+ // Check that express static gets called with correct options
403
+ should . exist ( expressStaticStub . firstCall . args ) ;
404
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
405
+
406
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
407
+ options . should . be . an . Object ( ) ;
408
+ options . should . have . property ( 'maxAge' ) ;
409
+ options . should . have . property ( 'fallthrough' , false ) ;
410
+
411
+ done ( ) ;
412
+ } ) ;
413
+ } ) ;
414
+
415
+ it ( 'should set fallthrough to false for nested files' , function ( done ) {
416
+ req . path = '/assets/style.css' ;
417
+
418
+ staticTheme ( ) ( req , res , function next ( ) {
419
+ // Specifically gets called twice
420
+ activeThemeStub . calledTwice . should . be . true ( ) ;
421
+ expressStaticStub . called . should . be . true ( ) ;
422
+
423
+ // Check that express static gets called with correct options
424
+ should . exist ( expressStaticStub . firstCall . args ) ;
425
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
426
+
427
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
428
+ options . should . be . an . Object ( ) ;
429
+ options . should . have . property ( 'maxAge' ) ;
430
+ options . should . have . property ( 'fallthrough' , false ) ;
431
+
432
+ done ( ) ;
433
+ } ) ;
434
+ } ) ;
435
+
436
+ it ( 'should set fallthrough to false for allowed special files like manifest.json' , function ( done ) {
437
+ req . path = '/manifest.json' ;
438
+
439
+ staticTheme ( ) ( req , res , function next ( ) {
440
+ // Specifically gets called twice
441
+ activeThemeStub . calledTwice . should . be . true ( ) ;
442
+ expressStaticStub . called . should . be . true ( ) ;
443
+
444
+ // Check that express static gets called with correct options
445
+ should . exist ( expressStaticStub . firstCall . args ) ;
446
+ expressStaticStub . firstCall . args [ 0 ] . should . eql ( 'my/fake/path' ) ;
447
+
448
+ const options = expressStaticStub . firstCall . args [ 1 ] ;
449
+ options . should . be . an . Object ( ) ;
450
+ options . should . have . property ( 'maxAge' ) ;
451
+ options . should . have . property ( 'fallthrough' , false ) ;
452
+
453
+ done ( ) ;
454
+ } ) ;
455
+ } ) ;
456
+ } ) ;
329
457
} ) ;
0 commit comments