Sync LMS backend source
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { AppService } from './app.service';
|
||||
import { PrismaService } from './prisma/prisma.service';
|
||||
|
||||
describe('AppService', () => {
|
||||
let service: AppService;
|
||||
let prisma: Pick<PrismaService, '$queryRaw'>;
|
||||
|
||||
beforeEach(() => {
|
||||
prisma = {
|
||||
$queryRaw: jest.fn().mockResolvedValue([{ '?column?': 1 }]),
|
||||
} as Pick<PrismaService, '$queryRaw'>;
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user