前段

Change-Id: I718d4d07ea03c6d2b6bcbd4d426c5d1af2201bf4
diff --git a/src/api/helpComment.test.js b/src/api/helpComment.test.js
new file mode 100644
index 0000000..2b7be4c
--- /dev/null
+++ b/src/api/helpComment.test.js
@@ -0,0 +1,45 @@
+import MockAdapter from 'axios-mock-adapter';

+import { api } from './auth'; // 添加api导入

+import { likePostComment, getCommentReplies, addCommentReply } from './helpComment';

+

+describe('求助帖评论API', () => {

+  let mockAxios;

+

+  beforeEach(() => {

+    mockAxios = new MockAdapter(api);

+  });

+

+  afterEach(() => {

+    mockAxios.restore();

+  });

+

+  describe('likePostComment - 点赞求助帖评论', () => {

+    it('应该成功发送点赞请求', async () => {

+      const mockResponse = { code: 200, message: '点赞成功' };

+      mockAxios.onPost('/help/comments/123/like').reply(200, mockResponse);

+

+      const response = await likePostComment('123');

+      expect(response.data).toEqual(mockResponse);

+    });

+  });

+

+  describe('getCommentReplies - 获取评论回复', () => {

+    it('应该返回正确的回复数据结构', async () => {

+      const mockData = [{ id: '1', content: '回复内容' }];

+      mockAxios.onGet('/help/comments/456/replies').reply(200, { code: 200, data: mockData });

+

+      const response = await getCommentReplies('456');

+      expect(response.data.data).toEqual(mockData);

+    });

+  });

+

+  describe('addCommentReply - 添加评论回复', () => {

+    it('应该正确发送回复内容', async () => {

+      const testData = { content: '测试回复', author: 'user1' };

+      mockAxios.onPost('/help/comments/789/replies', testData).reply(200, { code: 200 });

+

+      const response = await addCommentReply('789', testData);

+      expect(response.status).toBe(200);

+    });

+  });

+});
\ No newline at end of file