@@ -40,39 +40,14 @@ describe('stacks/server/resources.ts', () => {
4040 { } ,
4141 memorySize
4242 )
43+
44+ const functionName = await promiseOf ( functionURL . functionName )
45+ const authorizationType = await promiseOf ( functionURL . authorizationType )
4346
44- const protocolType = await promiseOf ( httpApi . protocolType )
45- const expectedApiId = await promiseOf ( httpApi . id )
46- const executionArn = await promiseOf ( httpApi . executionArn )
47+ expectTypeOf ( functionURL ) . toEqualTypeOf < aws . lambda . FunctionUrl > ( )
48+ expect ( authorizationType ) . toMatch ( 'NONE' )
4749
48- expectTypeOf ( httpApi ) . toEqualTypeOf < aws . apigatewayv2 . Api > ( )
49- expect ( protocolType ) . toMatch ( 'HTTP' )
50-
51- const routeKey = await promiseOf ( defaultRoute . routeKey )
52- const routeApiId = await promiseOf ( defaultRoute . apiId )
53-
54- await new Promise ( ( r ) => setTimeout ( r , 1000 ) )
55-
56- expectTypeOf ( defaultRoute ) . toEqualTypeOf < aws . apigatewayv2 . Route > ( )
57- expect ( routeKey ) . toMatch ( '$default' )
58- expect ( routeApiId ) . toMatch ( expectedApiId )
59-
60- const target = await promiseOf ( defaultRoute . target )
61- const integrationMatch = target ! . match ( 'integrations/(.*?)-id' )
62- const serverIntegrationName = integrationMatch ! [ 1 ]
63-
64- expect ( mocks . resources ) . toHaveProperty ( serverIntegrationName )
65- const serverIntegration = mocks . resources [ serverIntegrationName ]
66-
67- expect ( serverIntegration . type ) . toMatch (
68- 'aws:apigatewayv2/integration:Integration'
69- )
70- expect ( serverIntegration . apiId ) . toMatch ( expectedApiId )
71- expect ( serverIntegration . integrationMethod ) . toMatch ( 'POST' )
72- expect ( serverIntegration . integrationType ) . toMatch ( 'AWS_PROXY' )
73- expect ( serverIntegration . payloadFormatVersion ) . toMatch ( '1.0' )
74-
75- const lambdaMatch = serverIntegration . integrationUri . match ( '(.*?)-arn' )
50+ const lambdaMatch = functionName . match ( '(.*?)-arn' )
7651 const lambdaIntegrationName = lambdaMatch ! [ 1 ]
7752
7853 expect ( mocks . resources ) . toHaveProperty ( lambdaIntegrationName )
@@ -83,7 +58,7 @@ describe('stacks/server/resources.ts', () => {
8358 expect ( lambda . type ) . toMatch ( 'aws:lambda/function:Function' )
8459 expect ( lambda . handler ) . toMatch ( 'index.handler' )
8560 expect ( lambda . memorySize ) . toEqual ( memorySize )
86- expect ( lambda . runtime ) . toMatch ( 'nodejs16 .x' )
61+ expect ( lambda . runtime ) . toMatch ( 'nodejs18 .x' )
8762 expect ( lambda . timeout ) . toEqual ( 900 )
8863 expect ( lambda . role ) . toMatch ( iamArn )
8964 expect ( codePath ) . toMatch ( serverPath )
@@ -98,20 +73,6 @@ describe('stacks/server/resources.ts', () => {
9873 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
9974 )
10075
101- const serverPermission = findResource (
102- mocks ,
103- 'aws:lambda/permission:Permission'
104- )
105- expect ( serverPermission ) . toBeDefined ( )
106- expect ( serverPermission ! . action ) . toMatch ( 'lambda:InvokeFunction' )
107- expect ( serverPermission ! . principal ) . toMatch ( 'apigateway.amazonaws.com' )
108-
109- const sourceArnMatch = serverPermission ! . sourceArn . match ( '(.*?)/\\*/\\*' )
110- const sourceArn = sourceArnMatch ! [ 1 ]
111- expect ( sourceArn ) . toMatch ( executionArn )
112-
113- const functionId = await promiseOf ( serverPermission ! . function . id )
114- expect ( functionId ) . toMatch ( lambda . id )
11576 } )
11677
11778} )
0 commit comments