11// helper for parameterized tests (http://blog.piotrturski.net/2015/04/jasmine-parameterized-tests.html)
2- import { process as proxyIntegration , ProxyIntegrationConfig } from '../lib/proxyIntegration'
2+ import { ProxyIntegrationConfig , process as proxyIntegration } from '../lib/proxyIntegration'
3+
34import { APIGatewayProxyEvent } from 'aws-lambda'
45
56function forEach ( arrayOfArrays : any ) {
@@ -33,7 +34,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
3334 { path : '/123' , method : 'GET' , action : actionSpy }
3435 ]
3536 } , { httpMethod : 'GET' , path : '/123' } as APIGatewayProxyEvent , context )
36- expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } } , jasmine . anything ( ) )
37+ expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } , routePath : '/123' } , jasmine . anything ( ) )
3738 } )
3839
3940 it ( 'should select longer match' , ( ) => {
@@ -45,7 +46,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
4546 { path : '/123' , method : 'GET' , action : actionSpy }
4647 ]
4748 } , { httpMethod : 'GET' , path : '/123' } as APIGatewayProxyEvent , context )
48- expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } } , context )
49+ expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } , routePath : '/123' } , context )
4950 } )
5051 forEach ( [
5152 [ '/:param' ] ,
@@ -59,7 +60,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
5960 { path : path , method : 'GET' , action : actionSpy }
6061 ]
6162 } , { httpMethod : 'GET' , path : '/456' } as APIGatewayProxyEvent , context )
62- expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/456' , paths : { param : '456' } } , context )
63+ expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/456' , routePath : path , paths : { param : '456' } } , context )
6364 } )
6465 forEach ( [
6566 [ '/:param' ] ,
@@ -73,7 +74,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
7374 { path : path , method : 'GET' , action : ( ) => 'param' as any }
7475 ]
7576 } , { httpMethod : 'GET' , path : '/123' } as APIGatewayProxyEvent , context )
76- expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } } , context )
77+ expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , routePath : '/123' , paths : { } } , context )
7778 } )
7879 forEach ( [
7980 [ '/:param' ] ,
@@ -90,6 +91,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
9091 expect ( actionSpy ) . toHaveBeenCalledWith ( {
9192 httpMethod : 'GET' ,
9293 path : '/%2Fwirtschaft%2Farticle85883...tml' ,
94+ routePath : path ,
9395 paths : { param : '/wirtschaft/article85883...tml' }
9496 } , context )
9597 } )
@@ -106,6 +108,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
106108 expect ( actionSpy ) . toHaveBeenCalledWith ( {
107109 httpMethod : 'GET' ,
108110 path : '/%2Fdeutschland-bewegt-sich%2F' ,
111+ routePath : path ,
109112 paths : { param : '/deutschland-bewegt-sich/' }
110113 } , context )
111114 } )
@@ -125,6 +128,7 @@ describe('proxyIntegration.routeHandler.selection', () => {
125128 expect ( actionSpy ) . toHaveBeenCalledWith ( {
126129 httpMethod : 'GET' ,
127130 path : '/%2Fboerse%2FResources%2FImages%2Fcss%2Farrows_change-2.0.1.png?rfid=2013011501' ,
131+ routePath : path ,
128132 paths : { param : '/boerse/Resources/Images/css/arrows_change-2.0.1.png?rfid=2013011501' }
129133 } , context )
130134 } )
@@ -178,7 +182,7 @@ describe('proxyIntegration.routeHandler', () => {
178182 } , event as any , context as any )
179183
180184 expect ( actionSpy ) . toHaveBeenCalledWith ( {
181- httpMethod : 'GET' , headers : jasmine . anything ( ) , requestContext : jasmine . anything ( ) , path : '/' , paths : { }
185+ httpMethod : 'GET' , headers : jasmine . anything ( ) , requestContext : jasmine . anything ( ) , path : '/' , routePath : '/' , paths : { }
182186 } , context )
183187 } )
184188
@@ -197,7 +201,7 @@ describe('proxyIntegration.routeHandler', () => {
197201 } ]
198202 } , event as any , context )
199203 expect ( actionSpy ) . toHaveBeenCalledWith ( {
200- httpMethod : 'GET' , headers : jasmine . anything ( ) , requestContext : jasmine . anything ( ) , path : '/' , paths : { }
204+ httpMethod : 'GET' , headers : jasmine . anything ( ) , requestContext : jasmine . anything ( ) , path : '/' , routePath : '/' , paths : { }
201205 } , context )
202206 } )
203207 it ( 'should remove basepath from multi-slash-path if coming over custom domain name' , ( ) => {
@@ -219,6 +223,7 @@ describe('proxyIntegration.routeHandler', () => {
219223 headers : jasmine . anything ( ) ,
220224 requestContext : jasmine . anything ( ) ,
221225 path : '/123/456' ,
226+ routePath : '/123/456' ,
222227 paths : { }
223228 } , context )
224229 } )
@@ -299,7 +304,7 @@ describe('proxyIntegration.routeHandler', () => {
299304 ]
300305 }
301306 await proxyIntegration ( routeConfig , { path, httpMethod : 'GET' } as APIGatewayProxyEvent , context )
302- expect ( spiedAction ) . toHaveBeenCalledWith ( { path, httpMethod : 'GET' , paths : expectedPathValues } , context )
307+ expect ( spiedAction ) . toHaveBeenCalledWith ( { path, httpMethod : 'GET' , paths : expectedPathValues , routePath : pathConfig } , context )
303308 } )
304309
305310
@@ -446,6 +451,7 @@ describe('proxyIntegration.proxyPath', () => {
446451 resource : '/{apiPath+}' ,
447452 paths : { } ,
448453 path : '/article/list' ,
454+ routePath : '/article/list' ,
449455 httpMethod : 'GET' ,
450456 pathParameters : { apiPath : '/article/list' }
451457 } , context )
@@ -485,6 +491,7 @@ describe('proxyIntegration.proxyPath', () => {
485491 resource : '/{apiPath+}' ,
486492 paths : { } ,
487493 path : '/article/list' ,
494+ routePath : '/article/list' ,
488495 httpMethod : 'GET' ,
489496 pathParameters : { apiPath : '/article/list' }
490497 } , context )
@@ -500,6 +507,7 @@ describe('proxyIntegration.proxyPath', () => {
500507 resource : '/{apiPath+}' ,
501508 paths : { } ,
502509 path : '/section/list' ,
510+ routePath : '/section/list' ,
503511 httpMethod : 'GET' ,
504512 pathParameters : { apiPath : '/section/list' }
505513 } , context )
@@ -603,6 +611,7 @@ const assertPathIsUnchanged = async (hostname: string) => {
603611 headers : jasmine . anything ( ) ,
604612 requestContext : jasmine . anything ( ) ,
605613 path : '/123/456' ,
614+ routePath : '/123/456' ,
606615 paths : { }
607616 } , context )
608617}
0 commit comments