Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,62 @@ describe('startHttpServer', () => {
}
});

it('returns Content-Type text/plain on GET /healthz', async () => {
vi.doMock('../src/tools.js', () => ({
createMcpServer: () => ({ connect: vi.fn() }),
}));

const { startHttpServer } = await import('../src/server.js');
const httpServer = await startHttpServer(0);
const port = (httpServer.address() as any).port;

try {
const res = await fetch(`http://localhost:${port}/healthz`);
expect(res.status).toBe(200);
expect(res.headers.get('content-type')).toBe('text/plain');
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} finally {
httpServer.close();
}
});

it('returns 404 for POST /healthz', async () => {
vi.doMock('../src/tools.js', () => ({
createMcpServer: () => ({ connect: vi.fn() }),
}));

const { startHttpServer } = await import('../src/server.js');
const httpServer = await startHttpServer(0);
const port = (httpServer.address() as any).port;

try {
const res = await fetch(`http://localhost:${port}/healthz`, {
method: 'POST',
});
expect(res.status).toBe(404);
} finally {
httpServer.close();
}
});

it('returns 404 for PUT /healthz', async () => {
vi.doMock('../src/tools.js', () => ({
createMcpServer: () => ({ connect: vi.fn() }),
}));

const { startHttpServer } = await import('../src/server.js');
const httpServer = await startHttpServer(0);
const port = (httpServer.address() as any).port;

try {
const res = await fetch(`http://localhost:${port}/healthz`, {
method: 'PUT',
});
expect(res.status).toBe(404);
} finally {
httpServer.close();
}
});

it('returns 404 for unknown paths', async () => {
vi.doMock('../src/tools.js', () => ({
createMcpServer: () => ({ connect: vi.fn() }),
Expand Down
Loading