import { AppService } from './app.service'; import { PrismaService } from './prisma/prisma.service'; describe('AppService', () => { let service: AppService; let prisma: Pick; beforeEach(() => { prisma = { $queryRaw: jest.fn().mockResolvedValue([{ '?column?': 1 }]), } as Pick; service = new AppService(prisma as PrismaService); }); it('returns the root service status', () => { expect(service.getRoot()).toEqual({ service: 'lms-be', status: 'ok', }); }); it('returns a health payload', () => { expect(service.getHealth()).toMatchObject({ status: 'ok', }); }); it('checks database health', async () => { await expect(service.getDatabaseHealth()).resolves.toMatchObject({ status: 'ok', provider: 'postgresql', }); expect(prisma.$queryRaw).toHaveBeenCalled(); }); });