Skip to content

Commit b0842f1

Browse files
committed
up
1 parent f3cb863 commit b0842f1

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

tests/unit/json-migration-t038.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ describe('T038b-T038f: JSON Migration Tests', () => {
7575

7676
expect(product.images).toBeInstanceOf(Array);
7777
expect(product.images).toHaveLength(2);
78-
expect(product.images[0]).toBe('https://example.com/image1.jpg');
79-
expect(product.images[1]).toBe('https://example.com/image2.jpg');
78+
expect((product.images as string[])[0]).toBe('https://example.com/image1.jpg');
79+
expect((product.images as string[])[1]).toBe('https://example.com/image2.jpg');
8080
});
8181

8282
it('should retrieve images as Json array', async () => {
@@ -116,8 +116,8 @@ describe('T038b-T038f: JSON Migration Tests', () => {
116116

117117
expect(product?.metaKeywords).toBeInstanceOf(Array);
118118
expect(product?.metaKeywords).toHaveLength(2);
119-
expect(product?.metaKeywords[0]).toBe('test');
120-
expect(product?.metaKeywords[1]).toBe('product');
119+
expect((product?.metaKeywords as string[] | null)?.[0]).toBe('test');
120+
expect((product?.metaKeywords as string[] | null)?.[1]).toBe('product');
121121
});
122122

123123
it('should update metaKeywords as Json array', async () => {
@@ -245,7 +245,7 @@ describe('T038b-T038f: JSON Migration Tests', () => {
245245

246246
expect(review.images).toBeInstanceOf(Array);
247247
expect(review.images).toHaveLength(2);
248-
expect(review.images[0]).toBe('https://example.com/review1.jpg');
248+
expect((review.images as string[])[0]).toBe('https://example.com/review1.jpg');
249249
});
250250

251251
it('should retrieve review images as Json array', async () => {

tests/unit/services/payments/intent-validator-robustness.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)