44 createFunctionResource,
55 generateTemplate,
66} = require ( "../../scripts/generate-sam-template.js" ) ;
7+ const catalog = require ( "../utils/examples-catalog.json" ) ;
78
89describe ( "generate-sam-template" , ( ) => {
910 describe ( "toPascalCase" , ( ) => {
@@ -17,10 +18,15 @@ describe("generate-sam-template", () => {
1718
1819 describe ( "createFunctionResource" , ( ) => {
1920 test ( "creates default function resource" , ( ) => {
20- const resource = createFunctionResource ( "hello-world" ) ;
21+ const resource = createFunctionResource (
22+ "hello-world" ,
23+ catalog . find ( ( { handler } : { handler : string } ) => {
24+ return handler === "hello-world.handler" ;
25+ } ) ,
26+ ) ;
2127
2228 expect ( resource . Type ) . toBe ( "AWS::Serverless::Function" ) ;
23- expect ( resource . Properties . FunctionName ) . toBe ( "HelloWorld-TypeScript " ) ;
29+ expect ( resource . Properties . FunctionName ) . toBe ( "hello-world " ) ;
2430 expect ( resource . Properties . Handler ) . toBe ( "hello-world.handler" ) ;
2531 expect ( resource . Properties . Runtime ) . toBe ( "nodejs22.x" ) ;
2632 expect ( resource . Properties . MemorySize ) . toBe ( 128 ) ;
@@ -29,11 +35,14 @@ describe("generate-sam-template", () => {
2935 } ) ;
3036
3137 test ( "creates function resource with custom config for steps-with-retry" , ( ) => {
32- const resource = createFunctionResource ( "steps-with-retry" , { } ) ;
33-
34- expect ( resource . Properties . FunctionName ) . toBe (
35- "StepsWithRetry-TypeScript" ,
38+ const resource = createFunctionResource (
39+ "steps-with-retry" ,
40+ catalog . find ( ( { handler } : { handler : string } ) => {
41+ return handler === "steps-with-retry.handler" ;
42+ } ) ,
3643 ) ;
44+
45+ expect ( resource . Properties . FunctionName ) . toBe ( "steps-with-retry" ) ;
3746 expect ( resource . Properties . MemorySize ) . toBe ( 256 ) ;
3847 expect ( resource . Properties . Timeout ) . toBe ( 300 ) ;
3948 expect ( resource . Properties . Policies ) . toEqual ( [
@@ -48,15 +57,6 @@ describe("generate-sam-template", () => {
4857 test ( "includes required environment variables" , ( ) => {
4958 const resource = createFunctionResource ( "hello-world" , { } ) ;
5059
51- expect ( resource . Properties . Environment . Variables ) . toEqual ( {
52- AWS_ENDPOINT_URL_LAMBDA : "http://host.docker.internal:5000" ,
53- DURABLE_VERBOSE_MODE : "true" ,
54- } ) ;
55- } ) ;
56-
57- test ( "disables verbose logging when skipVerboseLogging is true" , ( ) => {
58- const resource = createFunctionResource ( "hello-world" , { } , true ) ;
59-
6060 expect ( resource . Properties . Environment . Variables ) . toEqual ( {
6161 AWS_ENDPOINT_URL_LAMBDA : "http://host.docker.internal:5000" ,
6262 DURABLE_VERBOSE_MODE : "false" ,
0 commit comments