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
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
800 B
TypeScript
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 });
|
|
});
|
|
});
|