From d1a980e2101cbfd8f46145970c1153b436e3f839 Mon Sep 17 00:00:00 2001 From: kikootwo Date: Thu, 14 May 2026 16:02:04 -0400 Subject: [PATCH] Enhance download-torrent test mocks Update tests/processors/download-torrent.processor.test.ts to better mock dependencies used by processDownloadTorrent. Add jobQueueMock.addNotificationJob.mockResolvedValue(undefined) to avoid unmocked job queue calls, and change prismaMock.request.update.mockResolvedValue from an empty object to include { type: 'audiobook', user: { plexUsername: 'testuser' } } in the affected test cases so the returned request shape matches code expectations. --- tests/processors/download-torrent.processor.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/processors/download-torrent.processor.test.ts b/tests/processors/download-torrent.processor.test.ts index 179b5f2..1d8d6fd 100644 --- a/tests/processors/download-torrent.processor.test.ts +++ b/tests/processors/download-torrent.processor.test.ts @@ -59,6 +59,7 @@ describe('processDownloadTorrent', () => { vi.clearAllMocks(); // Restore default implementations cleared by clearAllMocks configMock.getMany.mockResolvedValue({ prowlarr_api_key: null }); + jobQueueMock.addNotificationJob.mockResolvedValue(undefined); }); const torrentPayload = { @@ -110,7 +111,7 @@ describe('processDownloadTorrent', () => { enabled: true, category: 'readmeabook', }); - prismaMock.request.update.mockResolvedValue({}); + prismaMock.request.update.mockResolvedValue({ type: 'audiobook', user: { plexUsername: 'testuser' } }); prismaMock.downloadHistory.create.mockResolvedValue({ id: 'dh-1' }); const { processDownloadTorrent } = await import('@/lib/processors/download-torrent.processor'); @@ -141,7 +142,7 @@ describe('processDownloadTorrent', () => { enabled: true, category: 'readmeabook', }); - prismaMock.request.update.mockResolvedValue({}); + prismaMock.request.update.mockResolvedValue({ type: 'audiobook', user: { plexUsername: 'testuser' } }); prismaMock.downloadHistory.create.mockResolvedValue({ id: 'dh-2' }); const { processDownloadTorrent } = await import('@/lib/processors/download-torrent.processor'); @@ -186,7 +187,7 @@ describe('processDownloadTorrent', () => { enabled: true, category: 'readmeabook', }); - prismaMock.request.update.mockResolvedValue({}); + prismaMock.request.update.mockResolvedValue({ type: 'audiobook', user: { plexUsername: 'testuser' } }); prismaMock.downloadHistory.create.mockResolvedValue({ id: 'dh-1' }); const { processDownloadTorrent } = await import('@/lib/processors/download-torrent.processor');