Skip to content

Commit 0f46e45

Browse files
authored
Merge pull request #221 from OpenPathfinder/ulises/217
2 parents f301450 + 1c04e6c commit 0f46e45

File tree

5 files changed

+854
-90
lines changed

5 files changed

+854
-90
lines changed

__tests__/httpServer.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const request = require('supertest')
2+
const serverModule = require('../src/httpServer')
3+
const server = serverModule()
4+
const app = request(server)
5+
6+
// Cleanup after all tests
7+
afterAll(() => {
8+
server?.close()
9+
})
10+
11+
describe('HTTP Server API', () => {
12+
test('health check endpoint should return status ok', async () => {
13+
const response = await app.get('/api/v1/__health')
14+
15+
expect(response.status).toBe(200)
16+
expect(response.body).toHaveProperty('status', 'ok')
17+
expect(response.body).toHaveProperty('timestamp')
18+
19+
const timestamp = new Date(response.body.timestamp)
20+
expect(timestamp.toISOString()).toBe(response.body.timestamp)
21+
})
22+
23+
test('non-existent API endpoint should return 404', async () => {
24+
const response = await app.get('/api/v1/non-existent-endpoint')
25+
26+
expect(response.status).toBe(404)
27+
})
28+
})

0 commit comments

Comments
 (0)