@@ -16,13 +16,13 @@ function getNextStaticAsset(directory: string) {
1616 return path . join ( root , files [ 0 ] )
1717}
1818
19- function mockRequest ( path : string , { headers } : { headers ?: Record < string , string > } = { } ) {
19+ function mockRequest ( requestPath : string , { headers } : { headers ?: Record < string , string > } = { } ) {
2020 const _headers = Object . fromEntries (
2121 Object . entries ( headers || { } ) . map ( ( [ key , value ] ) => [ key . toLowerCase ( ) , value ] ) ,
2222 )
2323 return {
24- path,
25- url : path ,
24+ path : requestPath ,
25+ url : requestPath ,
2626 get : ( header : string ) => {
2727 return _headers [ header . toLowerCase ( ) ]
2828 } ,
@@ -74,8 +74,8 @@ const mockResponse = () => {
7474 if ( typeof key === 'string' ) {
7575 res . headers [ key . toLowerCase ( ) ] = value
7676 } else {
77- for ( const [ k , value ] of Object . entries ( key ) ) {
78- res . headers [ k . toLowerCase ( ) ] = value
77+ for ( const [ k , v ] of Object . entries ( key ) ) {
78+ res . headers [ k . toLowerCase ( ) ] = v
7979 }
8080 }
8181 }
@@ -319,9 +319,9 @@ describe('archived enterprise static assets', () => {
319319 } ,
320320 ] ) (
321321 'should return $expectStatus for $name' ,
322- ( { name, path, referrer, expectStatus, shouldCallNext } ) => {
322+ ( { name, path : testPath , referrer, expectStatus, shouldCallNext } ) => {
323323 test ( name , async ( ) => {
324- const req = mockRequest ( path , {
324+ const req = mockRequest ( testPath , {
325325 headers : {
326326 Referrer : referrer ,
327327 } ,
@@ -359,22 +359,25 @@ describe('archived enterprise static assets', () => {
359359 expectStatus : undefined ,
360360 shouldCallNext : true ,
361361 } ,
362- ] ) ( 'should not suppress $name' , ( { name, path, referrer, expectStatus, shouldCallNext } ) => {
363- test ( name , async ( ) => {
364- const req = mockRequest ( path , {
365- headers : {
366- Referrer : referrer ,
367- } ,
362+ ] ) (
363+ 'should not suppress $name' ,
364+ ( { name, path : testPath , referrer, expectStatus, shouldCallNext } ) => {
365+ test ( name , async ( ) => {
366+ const req = mockRequest ( testPath , {
367+ headers : {
368+ Referrer : referrer ,
369+ } ,
370+ } )
371+ const res = mockResponse ( )
372+ let nexted = false
373+ const next = ( ) => {
374+ nexted = true
375+ }
376+ setDefaultFastlySurrogateKey ( req , res , ( ) => { } )
377+ await archivedEnterpriseVersionsAssets ( req as any , res as any , next )
378+ expect ( nexted ) . toBe ( shouldCallNext )
379+ expect ( res . statusCode ) . toBe ( expectStatus )
368380 } )
369- const res = mockResponse ( )
370- let nexted = false
371- const next = ( ) => {
372- nexted = true
373- }
374- setDefaultFastlySurrogateKey ( req , res , ( ) => { } )
375- await archivedEnterpriseVersionsAssets ( req as any , res as any , next )
376- expect ( nexted ) . toBe ( shouldCallNext )
377- expect ( res . statusCode ) . toBe ( expectStatus )
378- } )
379- } )
381+ } ,
382+ )
380383} )
0 commit comments