mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
Add series fields to audiobooks and update related logic
Introduces 'series' and 'seriesPart' fields to the Audiobook model and database schema. Updates API routes, file organization, and path template utilities to support series metadata. Enhances chapter merging logic, improves notification backend testing, and expands test coverage for admin and API routes.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Component: Setup Status API Route Tests
|
||||
* Documentation: documentation/testing.md
|
||||
*/
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createPrismaMock } from '../helpers/prisma';
|
||||
|
||||
const prismaMock = createPrismaMock();
|
||||
|
||||
vi.mock('@/lib/db', () => ({
|
||||
prisma: prismaMock,
|
||||
}));
|
||||
|
||||
describe('Setup status route', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('returns true when setup_completed is true', async () => {
|
||||
prismaMock.configuration.findUnique.mockResolvedValueOnce({
|
||||
key: 'setup_completed',
|
||||
value: 'true',
|
||||
});
|
||||
|
||||
const { GET } = await import('@/app/api/setup/status/route');
|
||||
const response = await GET({} as any);
|
||||
const payload = await response.json();
|
||||
|
||||
expect(payload.setupComplete).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when setup_completed is missing', async () => {
|
||||
prismaMock.configuration.findUnique.mockResolvedValueOnce(null);
|
||||
|
||||
const { GET } = await import('@/app/api/setup/status/route');
|
||||
const response = await GET({} as any);
|
||||
const payload = await response.json();
|
||||
|
||||
expect(payload.setupComplete).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when the database lookup fails', async () => {
|
||||
prismaMock.configuration.findUnique.mockRejectedValueOnce(new Error('db not ready'));
|
||||
|
||||
const { GET } = await import('@/app/api/setup/status/route');
|
||||
const response = await GET({} as any);
|
||||
const payload = await response.json();
|
||||
|
||||
expect(payload.setupComplete).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user