@@ -122,13 +122,13 @@ describe('Payment Intent Validator Robustness (T041)', () => {
122122 // Mock database to fail first 2 attempts with timeout
123123 let attempts = 0 ;
124124 const originalFindFirst = db . payment . findFirst ;
125- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
125+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
126126 attempts ++ ;
127127 if ( attempts <= 2 ) {
128128 throw new Error ( 'ETIMEDOUT: Connection timed out' ) ;
129129 }
130- return originalFindFirst . call ( db . payment , { where : { } } ) as Promise < null > ;
131- } ) ;
130+ return originalFindFirst . call ( db . payment , { where : { } } ) as any ;
131+ } ) as any ) ;
132132
133133 const result = await validatePaymentIntent ( paymentIntentId , 1000 , storeId ) ;
134134
@@ -140,13 +140,13 @@ describe('Payment Intent Validator Robustness (T041)', () => {
140140 const paymentIntentId = 'pi_test_rate_limit' ;
141141
142142 let attempts = 0 ;
143- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
143+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
144144 attempts ++ ;
145145 if ( attempts === 1 ) {
146146 throw new Error ( 'rate_limit: Too many requests' ) ;
147147 }
148- return null ;
149- } ) ;
148+ return null as any ;
149+ } ) as any ) ;
150150
151151 const result = await validatePaymentIntent ( paymentIntentId , 1000 , storeId ) ;
152152
@@ -158,13 +158,13 @@ describe('Payment Intent Validator Robustness (T041)', () => {
158158 const paymentIntentId = 'pi_test_503' ;
159159
160160 let attempts = 0 ;
161- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
161+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
162162 attempts ++ ;
163163 if ( attempts === 1 ) {
164164 throw new Error ( 'HTTP 503: Service temporarily unavailable' ) ;
165165 }
166- return null ;
167- } ) ;
166+ return null as any ;
167+ } ) as any ) ;
168168
169169 const result = await validatePaymentIntent ( paymentIntentId , 1000 , storeId ) ;
170170
@@ -176,10 +176,10 @@ describe('Payment Intent Validator Robustness (T041)', () => {
176176 const paymentIntentId = 'pi_test_permanent' ;
177177
178178 let attempts = 0 ;
179- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
179+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
180180 attempts ++ ;
181181 throw new Error ( 'Permanent error: Invalid API key' ) ;
182- } ) ;
182+ } ) as any ) ;
183183
184184 await expect (
185185 validatePaymentIntent ( paymentIntentId , 1000 , storeId )
@@ -192,10 +192,10 @@ describe('Payment Intent Validator Robustness (T041)', () => {
192192 const paymentIntentId = 'pi_test_max_retries' ;
193193
194194 let attempts = 0 ;
195- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
195+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
196196 attempts ++ ;
197197 throw new Error ( 'ETIMEDOUT: Always fails' ) ;
198- } ) ;
198+ } ) as any ) ;
199199
200200 await expect (
201201 validatePaymentIntent ( paymentIntentId , 1000 , storeId )
@@ -210,7 +210,7 @@ describe('Payment Intent Validator Robustness (T041)', () => {
210210 let lastTime = Date . now ( ) ;
211211
212212 let attempts = 0 ;
213- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
213+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
214214 const now = Date . now ( ) ;
215215 if ( attempts > 0 ) {
216216 delays . push ( now - lastTime ) ;
@@ -222,7 +222,7 @@ describe('Payment Intent Validator Robustness (T041)', () => {
222222 throw new Error ( 'ETIMEDOUT' ) ;
223223 }
224224 return null ;
225- } ) ;
225+ } ) as any ) ;
226226
227227 await validatePaymentIntent ( paymentIntentId , 1000 , storeId ) ;
228228
@@ -239,7 +239,7 @@ describe('Payment Intent Validator Robustness (T041)', () => {
239239
240240 // Mock slow database query (35 seconds)
241241 vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation (
242- ( ) => new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( null ) , 35000 ) )
242+ ( ( ) => new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( null ) , 35000 ) ) ) as any
243243 ) ;
244244
245245 const startTime = Date . now ( ) ;
@@ -259,11 +259,11 @@ describe('Payment Intent Validator Robustness (T041)', () => {
259259
260260 let attempts = 0 ;
261261 vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation (
262- ( ) => new Promise ( ( resolve ) => {
262+ ( ( ) => new Promise ( ( resolve ) => {
263263 attempts ++ ;
264264 // Each attempt takes 31 seconds (exceeds timeout)
265265 setTimeout ( ( ) => resolve ( null ) , 31000 ) ;
266- } )
266+ } ) ) as any
267267 ) ;
268268
269269 const startTime = Date . now ( ) ;
@@ -298,7 +298,7 @@ describe('Payment Intent Validator Robustness (T041)', () => {
298298 const paymentIntentId = 'pi_test_temp_outage' ;
299299
300300 let attempts = 0 ;
301- vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( async ( ) => {
301+ vi . spyOn ( db . payment , 'findFirst' ) . mockImplementation ( ( async ( ) => {
302302 attempts ++ ;
303303 if ( attempts === 1 ) {
304304 throw new Error ( 'ECONNRESET: Provider connection reset' ) ;
@@ -307,7 +307,7 @@ describe('Payment Intent Validator Robustness (T041)', () => {
307307 throw new Error ( '503: Service temporarily unavailable' ) ;
308308 }
309309 return null ; // Provider recovered
310- } ) ;
310+ } ) as any ) ;
311311
312312 const result = await validatePaymentIntent ( paymentIntentId , 1000 , storeId ) ;
313313
0 commit comments