health.test.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import request from 'supertest';
  2. import { initializeParseServer } from '../../../src/config/parse-server';
  3. import { connectRedis } from '../../../src/config/redis';
  4. import { createApp } from '../../../src/app';
  5. describe('健康检查API测试', () => {
  6. let app: any;
  7. beforeAll(async () => {
  8. // 初始化Parse Server
  9. await initializeParseServer();
  10. // 初始化Redis
  11. await connectRedis();
  12. // 创建应用
  13. app = createApp();
  14. });
  15. it('GET /health 应该返回200状态码', async () => {
  16. const response = await request(app).get('/health');
  17. expect(response.status).toBe(200);
  18. expect(response.body).toHaveProperty('status', 'ok');
  19. });
  20. it('GET / 应该返回API信息', async () => {
  21. const response = await request(app).get('/');
  22. expect(response.status).toBe(200);
  23. expect(response.body).toHaveProperty('name');
  24. expect(response.body).toHaveProperty('version');
  25. });
  26. it('GET /api/v1/health 应该返回200状态码', async () => {
  27. const response = await request(app).get('/api/v1/health');
  28. expect(response.status).toBe(200);
  29. expect(response.body).toHaveProperty('status', 'ok');
  30. });
  31. });