@@ -47,35 +47,44 @@ describe('proxyIntegration.routeHandler.selection', () => {
4747 } , { httpMethod : 'GET' , path : '/123' } as APIGatewayProxyEvent , context )
4848 expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } } , context )
4949 } )
50- it ( 'should select parameter match' , ( ) => {
50+ forEach ( [
51+ [ '/:param' ] ,
52+ [ '/{param}' ]
53+ ] ) . it ( 'should select parameter match' , ( path ) => {
5154 const actionSpy = jasmine . createSpy ( 'action' )
5255 proxyIntegration ( {
5356 routes : [
5457 { path : '/' , method : 'GET' , action : ( ) => '/' as any } ,
5558 { path : '/123' , method : 'GET' , action : ( ) => '123' as any } ,
56- { path : '/:param' , method : 'GET' , action : actionSpy }
59+ { path : path , method : 'GET' , action : actionSpy }
5760 ]
5861 } , { httpMethod : 'GET' , path : '/456' } as APIGatewayProxyEvent , context )
5962 expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/456' , paths : { param : '456' } } , context )
6063 } )
61- it ( 'should select static match' , ( ) => {
64+ forEach ( [
65+ [ '/:param' ] ,
66+ [ '/{param}' ]
67+ ] ) . it ( 'should select static match' , ( path ) => {
6268 const actionSpy = jasmine . createSpy ( 'action' )
6369 proxyIntegration ( {
6470 routes : [
6571 { path : '/' , method : 'GET' , action : ( ) => '/' as any } ,
6672 { path : '/123' , method : 'GET' , action : actionSpy } ,
67- { path : '/:param' , method : 'GET' , action : ( ) => 'param' as any }
73+ { path : path , method : 'GET' , action : ( ) => 'param' as any }
6874 ]
6975 } , { httpMethod : 'GET' , path : '/123' } as APIGatewayProxyEvent , context )
7076 expect ( actionSpy ) . toHaveBeenCalledWith ( { httpMethod : 'GET' , path : '/123' , paths : { } } , context )
7177 } )
72- it ( 'should match urlencoded path' , ( ) => {
78+ forEach ( [
79+ [ '/:param' ] ,
80+ [ '/{param}' ]
81+ ] ) . it ( 'should match urlencoded path' , ( path ) => {
7382 const actionSpy = jasmine . createSpy ( 'action' )
7483 proxyIntegration ( {
7584 routes : [
7685 { path : '/' , method : 'GET' , action : ( ) => '/' as any } ,
7786 { path : '/123' , method : 'GET' , action : ( ) => '123' as any } ,
78- { path : '/:param' , method : 'GET' , action : actionSpy }
87+ { path : path , method : 'GET' , action : actionSpy }
7988 ]
8089 } , { httpMethod : 'GET' , path : '/%2Fwirtschaft%2Farticle85883...tml' } as APIGatewayProxyEvent , context )
8190 expect ( actionSpy ) . toHaveBeenCalledWith ( {
@@ -84,11 +93,14 @@ describe('proxyIntegration.routeHandler.selection', () => {
8493 paths : { param : '/wirtschaft/article85883...tml' }
8594 } , context )
8695 } )
87- it ( 'should select match containing hyphen' , ( ) => {
96+ forEach ( [
97+ [ '/:param' ] ,
98+ [ '/{param}' ]
99+ ] ) . it ( 'should select match containing hyphen' , ( path ) => {
88100 const actionSpy = jasmine . createSpy ( 'action' )
89101 proxyIntegration ( {
90102 routes : [
91- { path : '/:param' , method : 'GET' , action : actionSpy }
103+ { path : path , method : 'GET' , action : actionSpy }
92104 ]
93105 } , { httpMethod : 'GET' , path : '/%2Fdeutschland-bewegt-sich%2F' } as APIGatewayProxyEvent , context )
94106 expect ( actionSpy ) . toHaveBeenCalledWith ( {
@@ -97,11 +109,14 @@ describe('proxyIntegration.routeHandler.selection', () => {
97109 paths : { param : '/deutschland-bewegt-sich/' }
98110 } , context )
99111 } )
100- it ( 'should select match containing question marks and dots' , ( ) => {
112+ forEach ( [
113+ [ '/:param' ] ,
114+ [ '/{param}' ]
115+ ] ) . it ( 'should select match containing question marks and dots' , ( path ) => {
101116 const actionSpy = jasmine . createSpy ( 'action' )
102117 proxyIntegration ( {
103118 routes : [
104- { path : '/:param' , method : 'GET' , action : actionSpy }
119+ { path : path , method : 'GET' , action : actionSpy }
105120 ]
106121 } , {
107122 httpMethod : 'GET' ,
@@ -264,7 +279,14 @@ describe('proxyIntegration.routeHandler', () => {
264279 [ '/abc/:param1' , '/abc/p1' , { param1 : 'p1' } ] ,
265280 [ '/abc/def/:param1' , '/abc/def/p1' , { param1 : 'p1' } ] ,
266281 [ '/:param1/abc/:param2' , '/p1/abc/p2' , { param1 : 'p1' , param2 : 'p2' } ] ,
267- [ '/:param1/abc/def/:param2' , '/p1/abc/def/p2' , { param1 : 'p1' , param2 : 'p2' } ]
282+ [ '/:param1/abc/def/:param2' , '/p1/abc/def/p2' , { param1 : 'p1' , param2 : 'p2' } ] ,
283+ [ '/{param1}' , '/p1' , { param1 : 'p1' } ] ,
284+ [ '/abc/{param1}' , '/abc/p1' , { param1 : 'p1' } ] ,
285+ [ '/abc/def/{param1}' , '/abc/def/p1' , { param1 : 'p1' } ] ,
286+ [ '/{param1}/abc/{param2}' , '/p1/abc/p2' , { param1 : 'p1' , param2 : 'p2' } ] ,
287+ [ '/{param1}/abc/def/{param2}' , '/p1/abc/def/p2' , { param1 : 'p1' , param2 : 'p2' } ] ,
288+ [ '/:param1/abc/{param2}' , '/p1/abc/p2' , { param1 : 'p1' , param2 : 'p2' } ] ,
289+ [ '/{param1}/abc/def/:param2' , '/p1/abc/def/p2' , { param1 : 'p1' , param2 : 'p2' } ]
268290 ] ) . it ( 'should call action with path params for method/path' , async ( pathConfig , path , expectedPathValues ) => {
269291 const spiedAction = jasmine . createSpy ( 'action' ) . and . returnValue ( { foo : 'bar' } )
270292 const routeConfig : ProxyIntegrationConfig = {
0 commit comments