mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 22:28:10 +09:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
const request = require('supertest');
|
|
const app = require('../src/server');
|
|
|
|
describe('Server Tests', () => {
|
|
describe('GET /health', () => {
|
|
it('should return health status', async () => {
|
|
const response = await request(app)
|
|
.get('/health')
|
|
.expect(200);
|
|
|
|
expect(response.body).toHaveProperty('status', 'healthy');
|
|
expect(response.body).toHaveProperty('timestamp');
|
|
expect(response.body).toHaveProperty('uptime');
|
|
expect(response.body).toHaveProperty('environment');
|
|
});
|
|
});
|
|
|
|
describe('GET /api/v1', () => {
|
|
it('should return API information', async () => {
|
|
const response = await request(app)
|
|
.get('/api/v1')
|
|
.expect(200);
|
|
|
|
expect(response.body).toHaveProperty('message', 'REST API Example');
|
|
expect(response.body).toHaveProperty('version', '1.0.0');
|
|
expect(response.body).toHaveProperty('endpoints');
|
|
expect(response.body.endpoints).toHaveProperty('users');
|
|
expect(response.body.endpoints).toHaveProperty('products');
|
|
});
|
|
});
|
|
|
|
describe('404 Handler', () => {
|
|
it('should return 404 for unknown routes', async () => {
|
|
const response = await request(app)
|
|
.get('/unknown-route')
|
|
.expect(404);
|
|
|
|
expect(response.body).toHaveProperty('error', 'Not Found');
|
|
expect(response.body).toHaveProperty('message');
|
|
});
|
|
});
|
|
}); |