import { describe, expect, it } from 'vitest'; import { DocumentLoader } from '@/libs/document'; const createCaseMismatchEpub = async () => { const { ZipWriter, BlobWriter, TextReader } = await import('@zip.js/zip.js'); const writer = new ZipWriter(new BlobWriter('application/epub+zip')); await writer.add('mimetype', new TextReader('application/epub+zip'), { level: 0 }); await writer.add( 'META-INF/container.xml', new TextReader(` `), ); await writer.add( 'OPS/content.opf', new TextReader(` case-mismatch Case mismatch en `), ); await writer.add( 'OPS/text/chapter1.xhtml', new TextReader(` Case mismatch

Hello from the lowercase chapter entry.

`), ); const blob = await writer.close(); const arrayBuffer = await blob.arrayBuffer(); return new File([arrayBuffer], 'case-mismatch.epub', { type: 'application/epub+zip' }); }; describe('DocumentLoader EPUB zip lookup', () => { it('loads EPUB resources when manifest href casing differs from the zip entry', async () => { const file = await createCaseMismatchEpub(); const loader = new DocumentLoader(file); const { book, format } = await loader.open(); expect(format).toBe('EPUB'); const doc = await book.sections[0]!.createDocument(); expect(doc.body.textContent).toContain('Hello from the lowercase chapter entry.'); }); });