// This file is auto-generated by alef — DO NOT EDIT. // alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75 // To regenerate: alef generate // To verify freshness: alef verify --exit-code // Issues & docs: https://github.com/kreuzberg-dev/alef import { describe, expect, it } from 'vitest';import { extractFile, extractBytesSync, type ExtractionConfig } from '@kreuzberg/node'; function _alefE2eText(value: unknown): string { return value == null ? "" : String(value); } function _alefE2eItemTexts(item: unknown): string[] { if (item == null || typeof item !== "object") { return [_alefE2eText(item)]; } const record = item as Record; const itemsText = Array.isArray(record.items) ? record.items.map(_alefE2eText).join(" ") : ""; return [_alefE2eText(item), _alefE2eText(record.kind), _alefE2eText(record.name), _alefE2eText(record.source), _alefE2eText(record.alias), _alefE2eText(record.text), _alefE2eText(record.signature), itemsText]; } function _alefE2eFormatMetadataDisplay(fm: unknown): string { if (fm == null) return ""; if (typeof fm !== "object") return String(fm); const record = fm as Record; const formatType = record.format_type; // FormatMetadata is a tagged union: { format_type: 'image', image: { format: 'PNG', ... }, ... } // Extract the display string based on the variant type if (formatType === "image" && typeof record.image === "object") { const imageData = record.image as Record; if (typeof imageData.format === "string") return imageData.format; } // Fallback: return format_type variant name if (typeof record.format_type === "string") return record.format_type; return ""; } describe('error', () => { it('error_empty_bytes: Graceful handling of empty bytes (should not error)', async () => { const _content_content = await (await import('node:fs/promises')).readFile('text/empty.txt'); extractBytesSync(_content_content, "text/plain", undefined); }, 30000); it('error_empty_mime: Error when extracting with empty MIME type', async () => { await expect(async () => { const _content_content = await (await import('node:fs/promises')).readFile('text/plain.txt'); await extractBytesSync(_content_content, "", undefined); }).rejects.toThrow(); }, 30000); it('error_extract_bytes_conflicting_ocr: extract_bytes force+disable OCR', async () => { await expect(async () => { const _content_content = await (await import('node:fs/promises')).readFile('text/fake_text.txt'); await extractBytesSync(_content_content, "text/plain", { disableOcr: true, forceOcr: true } as ExtractionConfig); }).rejects.toThrow(); }, 30000); it('error_invalid_mime_format: Error when extracting with invalid MIME type format', async () => { await expect(async () => { const _content_content = await (await import('node:fs/promises')).readFile('text/plain.txt'); await extractBytesSync(_content_content, "not-a-mime", undefined); }).rejects.toThrow(); }, 30000); it('error_unsupported_mime: Error when extracting with unsupported MIME type', async () => { await expect(async () => { const _content_content = await (await import('node:fs/promises')).readFile('text/plain.txt'); await extractBytesSync(_content_content, "application/x-nonexistent", undefined); }).rejects.toThrow(); }, 30000); });