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.
This commit is contained in:
kikootwo
2026-05-14 16:02:04 -04:00
parent 5e4a38a340
commit d1a980e210
@@ -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');