mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
31bca0052f
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.
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
/**
|
|
* 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);
|
|
});
|
|
});
|