52 lines
1019 B
TypeScript
52 lines
1019 B
TypeScript
import { beforeAll, afterAll } from 'vitest'
|
|
import { prisma } from '../lib/prisma'
|
|
|
|
const delegates = [
|
|
'auditLog',
|
|
'adminPermission',
|
|
'adminUser',
|
|
'damagePoint',
|
|
'damageInspection',
|
|
'damageReport',
|
|
'additionalDriver',
|
|
'reservationInsurance',
|
|
'notificationPreference',
|
|
'notification',
|
|
'review',
|
|
'rentalPayment',
|
|
'reservation',
|
|
'customer',
|
|
'renterSavedCompany',
|
|
'renter',
|
|
'offerVehicle',
|
|
'offer',
|
|
'vehicleCalendarBlock',
|
|
'maintenanceLog',
|
|
'vehicle',
|
|
'employee',
|
|
'pricingRule',
|
|
'insurancePolicy',
|
|
'accountingSettings',
|
|
'contractSettings',
|
|
'brandSettings',
|
|
'subscriptionInvoice',
|
|
'subscription',
|
|
'company',
|
|
] as const
|
|
|
|
// Wipe all data between test files in a safe order that respects FK constraints.
|
|
async function cleanDatabase() {
|
|
for (const delegate of delegates) {
|
|
await (prisma as any)[delegate].deleteMany({})
|
|
}
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
await cleanDatabase()
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await cleanDatabase()
|
|
await prisma.$disconnect()
|
|
})
|