通知与推荐功能,css样式优化
Change-Id: I33d934bfdca88b7a8e6742be2a3c7323d28ffbcf
diff --git a/src/api/administer.test.js b/src/api/administer.test.js
index e5e785e..1b02c78 100644
--- a/src/api/administer.test.js
+++ b/src/api/administer.test.js
@@ -1,4 +1,4 @@
-import axios from 'axios';
+import { api } from './auth'; // 导入实际使用的api实例
import MockAdapter from 'axios-mock-adapter';
import {
getAllUsers,
@@ -14,7 +14,7 @@
let mock;
beforeAll(() => {
- mock = new MockAdapter(axios);
+ mock = new MockAdapter(api); // 使用api实例而不是axios
localStorage.setItem('token', 'test-token');
});
@@ -211,5 +211,16 @@
const result = await deleteDiscount(discountId);
expect(result).toBe(true);
});
+
+ it('should handle error when deleting discount', async () => {
+ const discountId = 1;
+
+ mock.onDelete(`/discount/delete/${discountId}`).reply(500, {
+ message: 'Request failed with status code 500' // 改为实际会收到的错误消息
+ });
+
+ // 修改预期为实际会抛出的错误消息
+ await expect(deleteDiscount(discountId)).rejects.toThrow('Request failed with status code 500');
+ });
});
});
\ No newline at end of file