通知与推荐功能,css样式优化
Change-Id: I33d934bfdca88b7a8e6742be2a3c7323d28ffbcf
diff --git a/src/api/notification.test.js b/src/api/notification.test.js
new file mode 100644
index 0000000..aef3cb7
--- /dev/null
+++ b/src/api/notification.test.js
@@ -0,0 +1,48 @@
+import MockAdapter from 'axios-mock-adapter';
+import { api } from './auth';
+import { notificationApi } from './notification';
+
+describe('通知API', () => {
+ let mockAxios;
+
+ beforeEach(() => {
+ mockAxios = new MockAdapter(api);
+ });
+
+ afterEach(() => {
+ mockAxios.restore();
+ });
+
+ describe('getNotifications - 获取通知列表', () => {
+ it('应该成功获取用户通知列表', async () => {
+ const userId = 'user123';
+ const mockData = [
+ { id: '1', message: '通知1', read: false },
+ { id: '2', message: '通知2', read: true }
+ ];
+
+ mockAxios.onGet('/api/notifications', { params: { userId } })
+ .reply(200, mockData);
+
+ const response = await notificationApi.getNotifications(userId);
+ expect(response).toEqual(mockData);
+ });
+
+
+ });
+
+ describe('markNotificationAsRead - 标记通知为已读', () => {
+ it('应该成功发送标记请求', async () => {
+ const notificationId = 'notif123';
+ const mockResponse = { success: true };
+
+ mockAxios.onPost(`/api/notifications/${notificationId}/read`)
+ .reply(200, mockResponse);
+
+ const response = await notificationApi.markNotificationAsRead(notificationId);
+ expect(response).toEqual(mockResponse);
+ });
+
+
+ });
+});
\ No newline at end of file