@@ -116,7 +116,7 @@ Top SKUs:
116116 } ) ;
117117
118118 it ( "should call makeDoitRequest with correct parameters and return success response" , async ( ) => {
119- const mockArgs = { filter : "platform:gcp" , pageToken : "next-page" } ;
119+ const mockArgs = { pageToken : "next-page" } ;
120120 const mockApiResponse = {
121121 rowCount : 1 ,
122122 anomalies : [
@@ -144,14 +144,14 @@ Top SKUs:
144144 const response = await handleAnomaliesRequest ( mockArgs , mockToken ) ;
145145
146146 expect ( makeDoitRequest ) . toHaveBeenCalledWith (
147- "https://api.doit.com/anomalies/v1?filter=platform%3Agcp& pageToken=next-page&maxResults=24 " ,
147+ "https://api.doit.com/anomalies/v1?pageToken=next-page&maxResults=32 " ,
148148 mockToken ,
149149 {
150150 method : "GET" ,
151151 }
152152 ) ;
153153 expect ( createSuccessResponse ) . toHaveBeenCalledWith (
154- expect . stringContaining ( "Found 1 anomalies (filtered by: platform:gcp) " )
154+ expect . stringContaining ( "Found 1 anomalies" )
155155 ) ;
156156 expect ( response ) . toEqual ( {
157157 content : [
@@ -161,7 +161,7 @@ Top SKUs:
161161 } ) ;
162162
163163 it ( "should handle no anomalies found" , async ( ) => {
164- const mockArgs = { filter : "platform:aws" } ;
164+ const mockArgs = { } ;
165165 const mockApiResponse = {
166166 rowCount : 0 ,
167167 anomalies : [ ] ,
@@ -172,7 +172,7 @@ Top SKUs:
172172 const response = await handleAnomaliesRequest ( mockArgs , mockToken ) ;
173173
174174 expect ( makeDoitRequest ) . toHaveBeenCalledWith (
175- "https://api.doit.com/anomalies/v1?filter=platform%3Aaws& maxResults=24 " ,
175+ "https://api.doit.com/anomalies/v1?maxResults=32 " ,
176176 mockToken ,
177177 {
178178 method : "GET" ,
@@ -191,7 +191,7 @@ Top SKUs:
191191 const response = await handleAnomaliesRequest ( mockArgs , mockToken ) ;
192192
193193 expect ( makeDoitRequest ) . toHaveBeenCalledWith (
194- "https://api.doit.com/anomalies/v1?maxResults=24 " ,
194+ "https://api.doit.com/anomalies/v1?maxResults=32 " ,
195195 mockToken ,
196196 { method : "GET" }
197197 ) ;
@@ -203,22 +203,6 @@ Top SKUs:
203203 } ) ;
204204 } ) ;
205205
206- it ( "should handle ZodError for invalid arguments" , async ( ) => {
207- const mockArgs = { filter : 123 } ; // Invalid filter type
208- const response = await handleAnomaliesRequest ( mockArgs , mockToken ) ;
209-
210- expect ( formatZodError ) . toHaveBeenCalled ( ) ;
211- expect ( createErrorResponse ) . toHaveBeenCalled ( ) ;
212- expect ( response ) . toEqual ( {
213- content : [
214- {
215- type : "text" ,
216- text : expect . stringContaining ( "Formatted Zod Error:" ) ,
217- } ,
218- ] ,
219- } ) ;
220- } ) ;
221-
222206 it ( "should handle general errors" , async ( ) => {
223207 const mockArgs = { } ;
224208 ( makeDoitRequest as vi . Mock ) . mockRejectedValue (
@@ -237,6 +221,23 @@ Top SKUs:
237221 ] ,
238222 } ) ;
239223 } ) ;
224+
225+ it ( "should handle ZodError for invalid arguments" , async ( ) => {
226+ const mockArgs = { pageToken : 123 } ; // Invalid argument type for Zod
227+ const response = await handleAnomaliesRequest ( mockArgs , mockToken ) ;
228+
229+ expect ( createErrorResponse ) . toHaveBeenCalledWith (
230+ expect . stringContaining ( "Formatted Zod Error:" )
231+ ) ;
232+ expect ( response ) . toEqual ( {
233+ content : [
234+ {
235+ type : "text" ,
236+ text : expect . stringContaining ( "Formatted Zod Error:" ) ,
237+ } ,
238+ ] ,
239+ } ) ;
240+ } ) ;
240241 } ) ;
241242
242243 describe ( "handleAnomalyRequest" , ( ) => {
0 commit comments