b93f5d5bdf
Adds test harness for the suite: - vitest.config.ts: happy-dom env, @/* alias, v8 coverage with 70% thresholds - setup.ts: env vars, global next/headers and next/navigation mocks - tsconfig.json: IDE alias resolution for test/ - __mocks__/prisma.ts: centralised Prisma mock auto-registered via vi.mock - fixtures/users.ts, fixtures/orders.ts: typed test data
54 lines
1.0 KiB
TypeScript
54 lines
1.0 KiB
TypeScript
import { mockUser } from './users'
|
|
|
|
export const mockOrder = {
|
|
id: 'order-1',
|
|
userId: mockUser.id,
|
|
status: 'PENDING' as const,
|
|
grandTotal: 2999,
|
|
currency: 'EUR',
|
|
createdAt: new Date('2024-01-01'),
|
|
updatedAt: new Date('2024-01-01'),
|
|
user: mockUser,
|
|
}
|
|
|
|
export const mockPayment = {
|
|
id: 'payment-1',
|
|
orderId: mockOrder.id,
|
|
provider: 'stripe',
|
|
providerPaymentId: 'pi_test_123',
|
|
status: 'pending',
|
|
amount: 2999,
|
|
currency: 'EUR',
|
|
rawPayload: {},
|
|
createdAt: new Date('2024-01-01'),
|
|
updatedAt: new Date('2024-01-01'),
|
|
}
|
|
|
|
export const mockStripeCheckoutEvent = {
|
|
type: 'checkout.session.completed',
|
|
data: {
|
|
object: {
|
|
metadata: { orderId: mockOrder.id },
|
|
payment_intent: 'pi_test_123',
|
|
},
|
|
},
|
|
}
|
|
|
|
export const mockStripePaymentSucceededEvent = {
|
|
type: 'payment_intent.succeeded',
|
|
data: {
|
|
object: {
|
|
id: 'pi_test_123',
|
|
},
|
|
},
|
|
}
|
|
|
|
export const mockStripePaymentFailedEvent = {
|
|
type: 'payment_intent.payment_failed',
|
|
data: {
|
|
object: {
|
|
id: 'pi_test_123',
|
|
},
|
|
},
|
|
}
|