mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 21:00:09 +00:00
Add test mocks and update delete API assertion
Add missing mocks used by updated code paths: mock PreferencesContext in profile page tests and add useReplaceWithTorrent/replaceWithTorrent mock for InteractiveTorrentSearchModal tests. Update Audiobookshelf API test to expect DELETE to include ?hard=1 and Authorization header. Extend the prisma test helper in audiobook-matcher tests with a reportedIssue.findMany mock and ensure it resolves to an empty array for the test.
This commit is contained in:
@@ -6,7 +6,12 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createPrismaMock } from '../helpers/prisma';
|
||||
|
||||
const prismaMock = createPrismaMock();
|
||||
const prismaMock = createPrismaMock() as ReturnType<typeof createPrismaMock> & {
|
||||
reportedIssue: { findMany: ReturnType<typeof vi.fn> };
|
||||
};
|
||||
|
||||
// Add reportedIssue mock (not yet in shared helper) for getOpenIssuesByAsins
|
||||
(prismaMock as any).reportedIssue = { findMany: vi.fn() };
|
||||
|
||||
vi.mock('@/lib/db', () => ({
|
||||
prisma: prismaMock,
|
||||
@@ -122,6 +127,9 @@ describe('audiobook-matcher', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
// Mock reported issues (none for this test)
|
||||
prismaMock.reportedIssue.findMany.mockResolvedValue([]);
|
||||
|
||||
const { enrichAudiobooksWithMatches } = await import('@/lib/utils/audiobook-matcher');
|
||||
const results = await enrichAudiobooksWithMatches(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user