@@ -76,6 +76,36 @@ describe('API Lambda handler', () => {
7676 } ) ;
7777 } ) ;
7878
79+ it ( "returns 400 if the limit parameter is not a number" , async ( ) => {
80+ const event = makeApiGwEvent ( {
81+ path : "/letters" ,
82+ queryStringParameters : { limit : "1%" } ,
83+ } ) ;
84+ const context = mockDeep < Context > ( ) ;
85+ const callback = jest . fn ( ) ;
86+ const result = await getLetters ( event , context , callback ) ;
87+
88+ expect ( result ) . toEqual ( {
89+ statusCode : 400 ,
90+ body : "Bad Request: limit parameter is not a number" ,
91+ } ) ;
92+ } ) ;
93+
94+ it ( "returns 400 if the limit parameter is not positive" , async ( ) => {
95+ const event = makeApiGwEvent ( {
96+ path : "/letters" ,
97+ queryStringParameters : { limit : "-1" } ,
98+ } ) ;
99+ const context = mockDeep < Context > ( ) ;
100+ const callback = jest . fn ( ) ;
101+ const result = await getLetters ( event , context , callback ) ;
102+
103+ expect ( result ) . toEqual ( {
104+ statusCode : 400 ,
105+ body : "Bad Request: limit parameter is not positive" ,
106+ } ) ;
107+ } ) ;
108+
79109 it ( 'returns 400 for missing supplier ID (empty headers)' , async ( ) => {
80110 const event = makeApiGwEvent ( { path : "/letters" , headers : { } } ) ;
81111 const context = mockDeep < Context > ( ) ;
0 commit comments