style: format and lint codebase using Biome v2

This commit is contained in:
MythEclipse
2026-05-18 07:29:01 +07:00
parent 3f4e697733
commit cf79a1f195
22 changed files with 638 additions and 528 deletions
+15 -15
View File
@@ -1,42 +1,42 @@
// @ts-nocheck
import { describe, it, expect, mock, beforeEach } from "bun:test";
import { beforeEach, describe, expect, it, mock } from 'bun:test';
// Mock database layer
const mockExecute = mock(() => Promise.resolve());
mock.module("../src/db/index", () => ({
mock.module('../src/db/index', () => ({
db: {
execute: mockExecute
}
execute: mockExecute,
},
}));
describe("Health Route Handler", () => {
let handleHealth;
describe('Health Route Handler', () => {
let handleHealth: any;
beforeEach(async () => {
mockExecute.mockClear();
const healthRoute = await import("../src/routes/health");
const healthRoute = await import('../src/routes/health');
handleHealth = healthRoute.handleHealth;
});
it("should return status 200 and ok when DB is healthy", async () => {
const req = new Request("http://localhost:3000/health");
it('should return status 200 and ok when DB is healthy', async () => {
const req = new Request('http://localhost:3000/health');
const res = await handleHealth(req);
expect(res.status).toBe(200);
const body = await res.json();
expect(body).toEqual({ status: "ok" });
expect(body).toEqual({ status: 'ok' });
expect(mockExecute).toHaveBeenCalled();
});
it("should return status 500 and error details when DB health check fails", async () => {
mockExecute.mockImplementationOnce(() => Promise.reject(new Error("DB Connection Failed")));
const req = new Request("http://localhost:3000/health");
it('should return status 500 and error details when DB health check fails', async () => {
mockExecute.mockImplementationOnce(() => Promise.reject(new Error('DB Connection Failed')));
const req = new Request('http://localhost:3000/health');
const res = await handleHealth(req);
expect(res.status).toBe(500);
const body = await res.json();
expect(body.status).toBe("error");
expect(body.error).toBe("DB Connection Failed");
expect(body.status).toBe('error');
expect(body.error).toBe('DB Connection Failed');
});
});