测试: 添加批量操作API测试
This commit is contained in:
parent
60746a29f1
commit
0c2c6f9d6b
38
tests/backend/batch.test.js
Normal file
38
tests/backend/batch.test.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 批量操作 API 测试
|
||||||
|
const request = require('supertest');
|
||||||
|
const app = require('../../backend/src/index');
|
||||||
|
|
||||||
|
describe('Batch API', () => {
|
||||||
|
let token;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const loginRes = await request(app)
|
||||||
|
.post('/api/auth/login')
|
||||||
|
.send({ username: 'testuser', password: 'test123' });
|
||||||
|
token = loginRes.body.token;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('POST /api/batch/delete', () => {
|
||||||
|
it('should batch delete files', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.post('/api/batch/delete')
|
||||||
|
.set('Authorization', `Bearer ${token}`)
|
||||||
|
.send({ fileIds: [1, 2, 3] });
|
||||||
|
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
expect(response.body).toHaveProperty('deleted');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('POST /api/batch/move', () => {
|
||||||
|
it('should batch move files', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.post('/api/batch/move')
|
||||||
|
.set('Authorization', `Bearer ${token}`)
|
||||||
|
.send({ fileIds: [1, 2], targetFolderId: 10 });
|
||||||
|
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
expect(response.body).toHaveProperty('moved');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user