Files
familienarchiv/frontend/src/routes/admin/ocr/global/page.server.spec.ts
Marcel 8acb830649
Some checks failed
CI / Backend Unit Tests (push) Failing after 2m45s
CI / Unit & Component Tests (pull_request) Failing after 2m32s
CI / OCR Service Tests (pull_request) Successful in 27s
CI / Backend Unit Tests (pull_request) Failing after 2m44s
CI / Unit & Component Tests (push) Failing after 2m35s
CI / OCR Service Tests (push) Successful in 30s
feat(admin): add OCR admin routes — overview, global history, sender detail
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 01:05:08 +02:00

28 lines
800 B
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
import { load } from './+page.server';
const mockApi = { GET: vi.fn() };
vi.mock('$lib/api.server', () => ({ createApiClient: () => mockApi }));
beforeEach(() => vi.clearAllMocks());
describe('admin/ocr/global — load', () => {
it('returns history from API', async () => {
mockApi.GET.mockResolvedValue({
response: { ok: true },
data: { runs: [{ id: 'run1' }], personNames: {} }
});
const result = (await load({ fetch } as never))!;
expect(result.history.runs).toHaveLength(1);
});
it('throws error when API call fails', async () => {
mockApi.GET.mockResolvedValue({ response: { ok: false, status: 500 }, error: {} });
await expect(load({ fetch } as never)).rejects.toMatchObject({ status: 500 });
});
});