|
|
@@ -135,26 +135,30 @@ describe('File API Integration Tests', () => {
|
|
|
expect(response.status).toBe(400);
|
|
|
});
|
|
|
|
|
|
- // it('should handle service errors gracefully', async () => {
|
|
|
- // const mockFileData = {
|
|
|
- // name: 'test.txt',
|
|
|
- // type: 'text/plain',
|
|
|
- // uploadUserId: 1
|
|
|
- // };
|
|
|
-
|
|
|
- // mockFileService.createFile = vi.fn().mockRejectedValue(new Error('Service error'));
|
|
|
-
|
|
|
- // const response = await client.files['upload-policy'].$post({
|
|
|
- // json: mockFileData
|
|
|
- // },
|
|
|
- // {
|
|
|
- // headers: {
|
|
|
- // 'Authorization': 'Bearer test-token'
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // expect(response.status).toBe(500);
|
|
|
- // });
|
|
|
+ it('should handle service errors gracefully', async () => {
|
|
|
+ const mockFileData = {
|
|
|
+ name: 'test.txt',
|
|
|
+ type: 'text/plain',
|
|
|
+ path: '/uploads/test.txt',
|
|
|
+ uploadUserId: 1
|
|
|
+ };
|
|
|
+
|
|
|
+ const mockCreateFile = vi.fn().mockRejectedValue(new Error('Service error'));
|
|
|
+ vi.mocked(FileService).mockImplementation(() => ({
|
|
|
+ createFile: mockCreateFile
|
|
|
+ } as unknown as FileService));
|
|
|
+
|
|
|
+ const response = await client.files['upload-policy'].$post({
|
|
|
+ json: mockFileData as any
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': 'Bearer test-token'
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(response.status).toBe(500);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
// describe('GET /api/v1/files/{id}/url', () => {
|