@@ -153,25 +153,6 @@ function get404ContentTypeHeader(name) {
153
153
}
154
154
}
155
155
156
- function applyTestMiddleware ( name , middlewares ) {
157
- middlewares . push ( {
158
- route : "/file.jpg" ,
159
- fn : ( req , res ) => {
160
- // Express API
161
- if ( res . send ) {
162
- res . send ( "welcome" ) ;
163
- }
164
- // Connect API
165
- else {
166
- res . setHeader ( "Content-Type" , "text/html" ) ;
167
- res . end ( "welcome" ) ;
168
- }
169
- } ,
170
- } ) ;
171
-
172
- return middlewares ;
173
- }
174
-
175
156
function parseHttpDate ( date ) {
176
157
const timestamp = date && Date . parse ( date ) ;
177
158
@@ -3519,237 +3500,6 @@ describe.each([
3519
3500
} ) ;
3520
3501
} ) ;
3521
3502
3522
- describe ( "headers option" , ( ) => {
3523
- describe ( "works with object" , ( ) => {
3524
- beforeEach ( async ( ) => {
3525
- const compiler = getCompiler ( webpackConfig ) ;
3526
-
3527
- [ server , req , instance ] = await frameworkFactory (
3528
- name ,
3529
- framework ,
3530
- compiler ,
3531
- {
3532
- headers : { "X-nonsense-1" : "yes" , "X-nonsense-2" : "no" } ,
3533
- } ,
3534
- {
3535
- setupMiddlewares : ( middlewares ) => {
3536
- applyTestMiddleware ( name , middlewares ) ;
3537
-
3538
- return middlewares ;
3539
- } ,
3540
- } ,
3541
- ) ;
3542
- } ) ;
3543
-
3544
- afterEach ( async ( ) => {
3545
- await close ( server , instance ) ;
3546
- } ) ;
3547
-
3548
- it ( 'should return the "200" code for the "GET" request to the bundle file and return headers' , async ( ) => {
3549
- const response = await req . get ( `/bundle.js` ) ;
3550
-
3551
- expect ( response . statusCode ) . toEqual ( 200 ) ;
3552
- expect ( response . headers [ "x-nonsense-1" ] ) . toEqual ( "yes" ) ;
3553
- expect ( response . headers [ "x-nonsense-2" ] ) . toEqual ( "no" ) ;
3554
- } ) ;
3555
-
3556
- it ( 'should return the "200" code for the "GET" request to path not in outputFileSystem but not return headers' , async ( ) => {
3557
- const res = await req . get ( "/file.jpg" ) ;
3558
- expect ( res . statusCode ) . toEqual ( 200 ) ;
3559
- expect ( res . headers [ "X-nonsense-1" ] ) . toBeUndefined ( ) ;
3560
- expect ( res . headers [ "X-nonsense-2" ] ) . toBeUndefined ( ) ;
3561
- } ) ;
3562
- } ) ;
3563
-
3564
- describe ( "works with array of objects" , ( ) => {
3565
- beforeEach ( async ( ) => {
3566
- const compiler = getCompiler ( webpackConfig ) ;
3567
-
3568
- [ server , req , instance ] = await frameworkFactory (
3569
- name ,
3570
- framework ,
3571
- compiler ,
3572
- {
3573
- headers : [
3574
- {
3575
- key : "X-Foo" ,
3576
- value : "value1" ,
3577
- } ,
3578
- {
3579
- key : "X-Bar" ,
3580
- value : "value2" ,
3581
- } ,
3582
- ] ,
3583
- } ,
3584
- {
3585
- setupMiddlewares : ( middlewares ) => {
3586
- applyTestMiddleware ( name , middlewares ) ;
3587
-
3588
- return middlewares ;
3589
- } ,
3590
- } ,
3591
- ) ;
3592
- } ) ;
3593
-
3594
- afterEach ( async ( ) => {
3595
- await close ( server , instance ) ;
3596
- } ) ;
3597
-
3598
- it ( 'should return the "200" code for the "GET" request to the bundle file and return headers' , async ( ) => {
3599
- const response = await req . get ( `/bundle.js` ) ;
3600
-
3601
- expect ( response . statusCode ) . toEqual ( 200 ) ;
3602
- expect ( response . headers [ "x-foo" ] ) . toEqual ( "value1" ) ;
3603
- expect ( response . headers [ "x-bar" ] ) . toEqual ( "value2" ) ;
3604
- } ) ;
3605
-
3606
- it ( 'should return the "200" code for the "GET" request to path not in outputFileSystem but not return headers' , async ( ) => {
3607
- const res = await req . get ( "/file.jpg" ) ;
3608
- expect ( res . statusCode ) . toEqual ( 200 ) ;
3609
- expect ( res . headers [ "x-foo" ] ) . toBeUndefined ( ) ;
3610
- expect ( res . headers [ "x-bar" ] ) . toBeUndefined ( ) ;
3611
- } ) ;
3612
- } ) ;
3613
-
3614
- describe ( "works with function" , ( ) => {
3615
- beforeEach ( async ( ) => {
3616
- const compiler = getCompiler ( webpackConfig ) ;
3617
-
3618
- [ server , req , instance ] = await frameworkFactory (
3619
- name ,
3620
- framework ,
3621
- compiler ,
3622
- {
3623
- headers : ( ) => {
3624
- return { "X-nonsense-1" : "yes" , "X-nonsense-2" : "no" } ;
3625
- } ,
3626
- } ,
3627
- {
3628
- setupMiddlewares : ( middlewares ) => {
3629
- applyTestMiddleware ( name , middlewares ) ;
3630
-
3631
- return middlewares ;
3632
- } ,
3633
- } ,
3634
- ) ;
3635
- } ) ;
3636
-
3637
- afterEach ( async ( ) => {
3638
- await close ( server , instance ) ;
3639
- } ) ;
3640
-
3641
- it ( 'should return the "200" code for the "GET" request to the bundle file and return headers' , async ( ) => {
3642
- const response = await req . get ( `/bundle.js` ) ;
3643
-
3644
- expect ( response . statusCode ) . toEqual ( 200 ) ;
3645
- expect ( response . headers [ "x-nonsense-1" ] ) . toEqual ( "yes" ) ;
3646
- expect ( response . headers [ "x-nonsense-2" ] ) . toEqual ( "no" ) ;
3647
- } ) ;
3648
-
3649
- it ( 'should return the "200" code for the "GET" request to path not in outputFileSystem but not return headers' , async ( ) => {
3650
- const res = await req . get ( "/file.jpg" ) ;
3651
- expect ( res . statusCode ) . toEqual ( 200 ) ;
3652
- expect ( res . headers [ "X-nonsense-1" ] ) . toBeUndefined ( ) ;
3653
- expect ( res . headers [ "X-nonsense-2" ] ) . toBeUndefined ( ) ;
3654
- } ) ;
3655
- } ) ;
3656
-
3657
- describe ( "works with function returning an array" , ( ) => {
3658
- beforeEach ( async ( ) => {
3659
- const compiler = getCompiler ( webpackConfig ) ;
3660
-
3661
- [ server , req , instance ] = await frameworkFactory (
3662
- name ,
3663
- framework ,
3664
- compiler ,
3665
- {
3666
- headers : ( ) => [
3667
- {
3668
- key : "X-Foo" ,
3669
- value : "value1" ,
3670
- } ,
3671
- {
3672
- key : "X-Bar" ,
3673
- value : "value2" ,
3674
- } ,
3675
- ] ,
3676
- } ,
3677
- {
3678
- setupMiddlewares : ( middlewares ) => {
3679
- applyTestMiddleware ( name , middlewares ) ;
3680
-
3681
- return middlewares ;
3682
- } ,
3683
- } ,
3684
- ) ;
3685
- } ) ;
3686
-
3687
- afterEach ( async ( ) => {
3688
- await close ( server , instance ) ;
3689
- } ) ;
3690
-
3691
- it ( 'should return the "200" code for the "GET" request to the bundle file and return headers' , async ( ) => {
3692
- const response = await req . get ( `/bundle.js` ) ;
3693
-
3694
- expect ( response . statusCode ) . toEqual ( 200 ) ;
3695
- expect ( response . headers [ "x-foo" ] ) . toEqual ( "value1" ) ;
3696
- expect ( response . headers [ "x-bar" ] ) . toEqual ( "value2" ) ;
3697
- } ) ;
3698
-
3699
- it ( 'should return the "200" code for the "GET" request to path not in outputFileSystem but not return headers' , async ( ) => {
3700
- const res = await req . get ( "/file.jpg" ) ;
3701
- expect ( res . statusCode ) . toEqual ( 200 ) ;
3702
- expect ( res . headers [ "x-foo" ] ) . toBeUndefined ( ) ;
3703
- expect ( res . headers [ "x-bar" ] ) . toBeUndefined ( ) ;
3704
- } ) ;
3705
- } ) ;
3706
-
3707
- describe ( "works with headers function with params" , ( ) => {
3708
- beforeEach ( async ( ) => {
3709
- const compiler = getCompiler ( webpackConfig ) ;
3710
-
3711
- [ server , req , instance ] = await frameworkFactory (
3712
- name ,
3713
- framework ,
3714
- compiler ,
3715
- {
3716
- // eslint-disable-next-line no-unused-vars, no-shadow
3717
- headers : ( req , res , context ) => {
3718
- res . setHeader ( "X-nonsense-1" , "yes" ) ;
3719
- res . setHeader ( "X-nonsense-2" , "no" ) ;
3720
- } ,
3721
- } ,
3722
- {
3723
- setupMiddlewares : ( middlewares ) => {
3724
- applyTestMiddleware ( name , middlewares ) ;
3725
-
3726
- return middlewares ;
3727
- } ,
3728
- } ,
3729
- ) ;
3730
- } ) ;
3731
-
3732
- afterEach ( async ( ) => {
3733
- await close ( server , instance ) ;
3734
- } ) ;
3735
-
3736
- it ( 'should return the "200" code for the "GET" request to the bundle file and return headers' , async ( ) => {
3737
- const response = await req . get ( `/bundle.js` ) ;
3738
-
3739
- expect ( response . statusCode ) . toEqual ( 200 ) ;
3740
- expect ( response . headers [ "x-nonsense-1" ] ) . toEqual ( "yes" ) ;
3741
- expect ( response . headers [ "x-nonsense-2" ] ) . toEqual ( "no" ) ;
3742
- } ) ;
3743
-
3744
- it ( 'should return the "200" code for the "GET" request to path not in outputFileSystem but not return headers' , async ( ) => {
3745
- const res = await req . get ( "/file.jpg" ) ;
3746
- expect ( res . statusCode ) . toEqual ( 200 ) ;
3747
- expect ( res . headers [ "X-nonsense-1" ] ) . toBeUndefined ( ) ;
3748
- expect ( res . headers [ "X-nonsense-2" ] ) . toBeUndefined ( ) ;
3749
- } ) ;
3750
- } ) ;
3751
- } ) ;
3752
-
3753
3503
describe ( "publicPath option" , ( ) => {
3754
3504
describe ( 'should work with "string" value' , ( ) => {
3755
3505
beforeAll ( async ( ) => {
0 commit comments