mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
94dbaf073b
Introduced a Vitest-based backend unit testing framework with supporting scripts, helpers, and GitHub Actions integration. Refactored the admin settings page to a modular architecture, splitting monolithic logic into feature-specific tabs and hooks for improved maintainability and testability. Updated documentation to reflect the new testing setup and settings architecture, and added new dependencies for testing utilities.
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/**
|
|
* Component: Prisma Mock Factory
|
|
* Documentation: documentation/backend/database.md
|
|
*/
|
|
|
|
import { vi } from 'vitest';
|
|
|
|
type PrismaModelMock = {
|
|
findMany: ReturnType<typeof vi.fn>;
|
|
findFirst: ReturnType<typeof vi.fn>;
|
|
findUnique: ReturnType<typeof vi.fn>;
|
|
create: ReturnType<typeof vi.fn>;
|
|
update: ReturnType<typeof vi.fn>;
|
|
updateMany: ReturnType<typeof vi.fn>;
|
|
upsert: ReturnType<typeof vi.fn>;
|
|
delete: ReturnType<typeof vi.fn>;
|
|
deleteMany: ReturnType<typeof vi.fn>;
|
|
count: ReturnType<typeof vi.fn>;
|
|
};
|
|
|
|
const createModelMock = (): PrismaModelMock => ({
|
|
findMany: vi.fn(),
|
|
findFirst: vi.fn(),
|
|
findUnique: vi.fn(),
|
|
create: vi.fn(() => Promise.resolve({})),
|
|
update: vi.fn(),
|
|
updateMany: vi.fn(),
|
|
upsert: vi.fn(),
|
|
delete: vi.fn(),
|
|
deleteMany: vi.fn(),
|
|
count: vi.fn(),
|
|
});
|
|
|
|
export const createPrismaMock = () => ({
|
|
configuration: createModelMock(),
|
|
user: createModelMock(),
|
|
request: createModelMock(),
|
|
audiobook: createModelMock(),
|
|
downloadHistory: createModelMock(),
|
|
plexLibrary: createModelMock(),
|
|
audibleCache: createModelMock(),
|
|
job: createModelMock(),
|
|
jobEvent: createModelMock(),
|
|
scheduledJob: createModelMock(),
|
|
bookDateConfig: createModelMock(),
|
|
bookDateRecommendation: createModelMock(),
|
|
bookDateSwipe: createModelMock(),
|
|
$queryRaw: vi.fn(),
|
|
$disconnect: vi.fn(),
|
|
});
|