@@ -290,7 +290,6 @@ describe.each([
290
290
request ( app )
291
291
. get ( '/unknown' )
292
292
. expect ( 'Content-Length' , fileData . byteLength . toString ( ) )
293
- . expect ( 'Content-Type' , 'application/octet-stream' )
294
293
. expect ( 200 , done ) ;
295
294
} ) ;
296
295
} ) ;
@@ -584,7 +583,6 @@ describe.each([
584
583
urls : [
585
584
{
586
585
value : 'filename-name-with-dots/mono-v6.x.x' ,
587
- contentType : 'application/octet-stream' ,
588
586
code : 200 ,
589
587
} ,
590
588
] ,
@@ -595,7 +593,6 @@ describe.each([
595
593
urls : [
596
594
{
597
595
value : 'noextension' ,
598
- contentType : 'application/octet-stream' ,
599
596
code : 200 ,
600
597
} ,
601
598
] ,
@@ -812,12 +809,19 @@ describe.each([
812
809
it ( `should return the "${ code } " code for the "GET" request for the "${ value } " url` , ( done ) => {
813
810
request ( app )
814
811
. get ( `${ publicPathForRequest } ${ value } ` )
815
- . expect ( 'Content-Type' , contentType )
816
812
. expect (
817
813
'Content-Length' ,
818
814
data ? String ( data . length ) : / \d + /
819
815
)
820
- . expect ( code , done ) ;
816
+ . expect ( code )
817
+ . then ( ( res ) => {
818
+ if ( contentType ) {
819
+ expect ( res . headers [ 'content-type' ] ) . toEqual (
820
+ contentType
821
+ ) ;
822
+ }
823
+ } )
824
+ . then ( done ) ;
821
825
} ) ;
822
826
}
823
827
}
@@ -835,11 +839,14 @@ describe.each([
835
839
app . use ( ( req , res , next ) => {
836
840
// Express API
837
841
if ( res . set ) {
838
- res . set ( 'Content-Type' , 'application/octet-stream' ) ;
842
+ res . set ( 'Content-Type' , 'application/vnd.test+ octet-stream' ) ;
839
843
}
840
844
// Connect API
841
845
else {
842
- res . setHeader ( 'Content-Type' , 'application/octet-stream' ) ;
846
+ res . setHeader (
847
+ 'Content-Type' ,
848
+ 'application/vnd.test+octet-stream'
849
+ ) ;
843
850
}
844
851
next ( ) ;
845
852
} ) ;
@@ -850,10 +857,10 @@ describe.each([
850
857
851
858
afterAll ( close ) ;
852
859
853
- it ( 'should not guess a MIME type if the "Content-Type" header is found ' , ( done ) => {
860
+ it ( 'should not modify the "Content-Type" header' , ( done ) => {
854
861
request ( app )
855
862
. get ( '/bundle.js' )
856
- . expect ( 'Content-Type' , 'application/octet-stream' )
863
+ . expect ( 'Content-Type' , 'application/vnd.test+ octet-stream' )
857
864
. expect ( 200 , done ) ;
858
865
} ) ;
859
866
} ) ;
@@ -2019,43 +2026,6 @@ describe.each([
2019
2026
} ) ;
2020
2027
} ) ;
2021
2028
2022
- describe ( 'should set the correct value for "Content-Type" header to unknown MIME type' , ( ) => {
2023
- beforeAll ( ( done ) => {
2024
- const outputPath = path . resolve ( __dirname , './outputs/basic' ) ;
2025
- const compiler = getCompiler ( {
2026
- ...webpackConfig ,
2027
- output : {
2028
- filename : 'bundle.js' ,
2029
- path : outputPath ,
2030
- } ,
2031
- } ) ;
2032
-
2033
- instance = middleware ( compiler ) ;
2034
-
2035
- app = framework ( ) ;
2036
- app . use ( instance ) ;
2037
-
2038
- listen = listenShorthand ( done ) ;
2039
-
2040
- instance . context . outputFileSystem . mkdirSync ( outputPath , {
2041
- recursive : true ,
2042
- } ) ;
2043
- instance . context . outputFileSystem . writeFileSync (
2044
- path . resolve ( outputPath , 'file.phtml' ) ,
2045
- 'welcome'
2046
- ) ;
2047
- } ) ;
2048
-
2049
- afterAll ( close ) ;
2050
-
2051
- it ( 'should return the "200" code for the "GET" request to "file.phtml"' , ( done ) => {
2052
- request ( app )
2053
- . get ( '/file.phtml' )
2054
- . expect ( 'Content-Type' , 'application/octet-stream' )
2055
- . expect ( 200 , done ) ;
2056
- } ) ;
2057
- } ) ;
2058
-
2059
2029
describe ( 'should set the correct value for "Content-Type" header to specified MIME type' , ( ) => {
2060
2030
beforeAll ( ( done ) => {
2061
2031
const outputPath = path . resolve ( __dirname , './outputs/basic' ) ;
@@ -2110,7 +2080,7 @@ describe.each([
2110
2080
2111
2081
instance = middleware ( compiler , {
2112
2082
mimeTypes : {
2113
- jpg : 'application/octet-stream ' ,
2083
+ jpg : 'image/vnd.test+jpeg ' ,
2114
2084
} ,
2115
2085
} ) ;
2116
2086
@@ -2133,7 +2103,7 @@ describe.each([
2133
2103
it ( 'should return the "200" code for the "GET" request "file.jpg"' , ( done ) => {
2134
2104
request ( app )
2135
2105
. get ( '/file.jpg' )
2136
- . expect ( 'Content-Type' , / a p p l i c a t i o n \/ o c t e t - s t r e a m / )
2106
+ . expect ( 'Content-Type' , 'image/vnd.test+jpeg' )
2137
2107
. expect ( 200 , done ) ;
2138
2108
} ) ;
2139
2109
} ) ;
@@ -2151,7 +2121,7 @@ describe.each([
2151
2121
2152
2122
instance = middleware ( compiler , {
2153
2123
mimeTypes : {
2154
- jpg : 'application/octet-stream ' ,
2124
+ jpg : 'image/vnd.test+jpeg ' ,
2155
2125
} ,
2156
2126
} ) ;
2157
2127
@@ -3225,10 +3195,7 @@ describe.each([
3225
3195
afterAll ( close ) ;
3226
3196
3227
3197
it ( 'should return the "200" code for the "GET" request to the public path' , ( done ) => {
3228
- request ( app )
3229
- . get ( '/' )
3230
- . expect ( 'Content-Type' , 'application/octet-stream' )
3231
- . expect ( 200 , done ) ;
3198
+ request ( app ) . get ( '/' ) . expect ( 200 , done ) ;
3232
3199
} ) ;
3233
3200
} ) ;
3234
3201
@@ -3305,10 +3272,7 @@ describe.each([
3305
3272
afterAll ( close ) ;
3306
3273
3307
3274
it ( 'should return the "200" code for the "GET" request to the public path' , ( done ) => {
3308
- request ( app )
3309
- . get ( '/' )
3310
- . expect ( 'Content-Type' , 'application/octet-stream' )
3311
- . expect ( 200 , done ) ;
3275
+ request ( app ) . get ( '/' ) . expect ( 200 , done ) ;
3312
3276
} ) ;
3313
3277
} ) ;
3314
3278
0 commit comments