import { expectType, expectAssignable } from 'tsd'; import * as pdf2html from 'pdf2html'; // Test basic function return types expectType>(pdf2html.html('test.pdf')); expectType>(pdf2html.html(Buffer.from('test'))); expectType>(pdf2html.text('test.pdf')); expectType>(pdf2html.pages('test.pdf')); expectType>(pdf2html.meta('test.pdf')); expectType>(pdf2html.thumbnail('test.pdf')); // Test with options expectType>(pdf2html.html('test.pdf', { maxBuffer: 1000 })); expectType>(pdf2html.pages('test.pdf', { text: true })); expectType>( pdf2html.thumbnail('test.pdf', { page: 1, imageType: 'png', width: 200, height: 300, }) ); // Test invalid inputs should produce errors // @ts-expect-error pdf2html.html(123); pdf2html.html(null); // @ts-expect-error pdf2html.html({}); // Test options assignability expectAssignable({}); expectAssignable({ maxBuffer: 1000 }); expectAssignable({ text: true }); expectAssignable({ text: false, maxBuffer: 1000 }); expectAssignable({ page: 1 }); expectAssignable({ imageType: 'png' }); expectAssignable({ imageType: 'jpg' }); // Test invalid imageType // @ts-expect-error const invalidThumbOptions: pdf2html.ThumbnailOptions = { imageType: 'gif' }; // Test PDFProcessingError const error = new pdf2html.PDFProcessingError('test', 'command', 1); expectType(error.message); expectType(error.command); expectType(error.exitCode); // Test PDFProcessor class expectType>(pdf2html.PDFProcessor.toHTML('test.pdf')); expectType>(pdf2html.PDFProcessor.toPages('test.pdf')); expectType>(pdf2html.PDFProcessor.toText('test.pdf')); expectType>(pdf2html.PDFProcessor.extractMetadata('test.pdf')); expectType>(pdf2html.PDFProcessor.generateThumbnail('test.pdf')); // Test utility classes exist expectType(pdf2html.utils.CommandExecutor); expectType(pdf2html.utils.ImageProcessor); expectType(pdf2html.utils.FileManager); expectType(pdf2html.utils.HTMLParser); // Test PDFInput type const stringInput: pdf2html.PDFInput = 'test.pdf'; const bufferInput: pdf2html.PDFInput = Buffer.from('test'); // Test metadata structure async function testMetadata() { const meta = await pdf2html.meta('test.pdf'); expectType(meta['pdf:PDFVersion']); expectType(meta.resourceName); expectType(meta.customProperty); // Should allow any property }