import { Test, TestingModule } from '@nestjs/testing'; import { PrismaService } from './prisma.service'; describe('PrismaService', () => { let prisma: PrismaService; beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [PrismaService], }).compile(); prisma = module.get(PrismaService); await prisma.onModuleInit(); }); afterAll(async () => { await prisma.onModuleDestroy(); }); it('connects to postgres', async () => { const result = await prisma.$queryRaw<[{ ok: bigint }]>`SELECT 1 AS ok`; expect(Number(result[0]!.ok)).toBe(1); }); it('creates and retrieves a Group, then cleans up', async () => { const group = await prisma.group.create({ data: { platform: 'whatsapp', platformId: `test-group-${Date.now()}@g.us`, name: 'Test Group', }, }); expect(group.id).toBeDefined(); expect(group.platform).toBe('whatsapp'); expect(group.isActive).toBe(true); await prisma.group.delete({ where: { id: group.id } }); }); });