| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import request from 'supertest';
- import { initializeParseServer } from '../../../src/config/parse-server';
- import { connectRedis } from '../../../src/config/redis';
- import { createApp } from '../../../src/app';
- describe('健康检查API测试', () => {
- let app: any;
- beforeAll(async () => {
- // 初始化Parse Server
- await initializeParseServer();
- // 初始化Redis
- await connectRedis();
- // 创建应用
- app = createApp();
- });
- it('GET /health 应该返回200状态码', async () => {
- const response = await request(app).get('/health');
-
- expect(response.status).toBe(200);
- expect(response.body).toHaveProperty('status', 'ok');
- });
- it('GET / 应该返回API信息', async () => {
- const response = await request(app).get('/');
-
- expect(response.status).toBe(200);
- expect(response.body).toHaveProperty('name');
- expect(response.body).toHaveProperty('version');
- });
- it('GET /api/v1/health 应该返回200状态码', async () => {
- const response = await request(app).get('/api/v1/health');
-
- expect(response.status).toBe(200);
- expect(response.body).toHaveProperty('status', 'ok');
- });
- });
|