@@ -17,6 +17,25 @@ const {
1717const { mockClient} = require ( 'aws-sdk-client-mock' )
1818const { ServiceException} = require ( '@smithy/smithy-client' )
1919
20+ const pathsToCheck = [
21+ [ '/' , 200 , 'application/json; charset=utf-8' ] ,
22+ [ '/tls' , 200 , 'application/json; charset=utf-8' ] ,
23+ [ '/exception' , 500 , 'text/html; charset=utf-8' ] ,
24+ [ '/cache' , 200 , 'application/json; charset=utf-8' ] ,
25+ [ '/cookie' , 200 , 'application/json; charset=utf-8' ] ,
26+ [ '/set-response-headers' , 200 , 'application/json; charset=utf-8' ] ,
27+ [ '/isolation' , 200 , 'application/json; charset=utf-8' ] ,
28+ [ '/memtest' , 200 , 'application/json; charset=utf-8' ] ,
29+ [ '/streaming-large' , 200 , 'application/json; charset=utf-8' ]
30+ ]
31+ const pathsToCheckWithBasePath = ( basePath ) => {
32+ return pathsToCheck . map ( ( pathStatusContentType ) => [
33+ basePath + pathStatusContentType [ 0 ] ,
34+ pathStatusContentType [ 1 ] ,
35+ pathStatusContentType [ 2 ]
36+ ] )
37+ }
38+
2039class AccessDenied extends ServiceException {
2140 constructor ( options ) {
2241 super ( { ...options , name : 'AccessDenied' } )
@@ -53,23 +72,26 @@ describe('server', () => {
5372 process . env = originalEnv
5473 jest . restoreAllMocks ( )
5574 } )
56- test . each ( [
57- [ '/' , 200 , 'application/json; charset=utf-8' ] ,
58- [ '/tls' , 200 , 'application/json; charset=utf-8' ] ,
59- [ '/exception' , 500 , 'text/html; charset=utf-8' ] ,
60- [ '/cache' , 200 , 'application/json; charset=utf-8' ] ,
61- [ '/cookie' , 200 , 'application/json; charset=utf-8' ] ,
62- [ '/multi-cookies' , 200 , 'application/json; charset=utf-8' ] ,
63- [ '/set-response-headers' , 200 , 'application/json; charset=utf-8' ] ,
64- [ '/isolation' , 200 , 'application/json; charset=utf-8' ] ,
65- [ '/memtest' , 200 , 'application/json; charset=utf-8' ] ,
66- [ '/streaming-large' , 200 , 'application/json; charset=utf-8' ]
67- ] ) ( 'Path %p should render correctly' , ( path , expectedStatus , expectedContentType ) => {
68- return request ( app )
69- . get ( path )
70- . expect ( expectedStatus )
71- . expect ( 'Content-Type' , expectedContentType )
72- } )
75+ test . each ( pathsToCheck ) (
76+ 'Path %p should render correctly' ,
77+ ( path , expectedStatus , expectedContentType ) => {
78+ return request ( app )
79+ . get ( path )
80+ . expect ( expectedStatus )
81+ . expect ( 'Content-Type' , expectedContentType )
82+ }
83+ )
84+
85+ test . each ( pathsToCheckWithBasePath ( '/test-base-path' ) ) (
86+ 'Path %p should render correctly' ,
87+ ( path , expectedStatus , expectedContentType ) => {
88+ process . env . MRT_ENV_BASE_PATH = '/test-base-path'
89+ return request ( app )
90+ . get ( path )
91+ . expect ( expectedStatus )
92+ . expect ( 'Content-Type' , expectedContentType )
93+ }
94+ )
7395
7496 test ( 'Path "/cache" has Cache-Control set' , ( ) => {
7597 return request ( app ) . get ( '/cache' ) . expect ( 'Cache-Control' , 's-maxage=60' )
0 commit comments