fix(compliance): improve compliance

This commit is contained in:
2025-05-28 10:26:26 +00:00
parent 5928948cfd
commit bc6e2e1829
4 changed files with 71 additions and 16 deletions

View File

@ -106,10 +106,11 @@ tap.test('PDF-12: Create PDFs with different version headers', async () => {
// Test processing
try {
const einvoice = await EInvoice.fromPdf(pdfBytes);
const einvoice = await EInvoice.fromPdf(Buffer.from(pdfBytes));
// Use detected format if available, otherwise handle the error
if (einvoice.format) {
const xml = einvoice.toXmlString(einvoice.format);
const format = einvoice.getFormat();
if (format && format !== 'unknown') {
const xml = einvoice.toXmlString('facturx');
expect(xml).toContain(`PDF-VER-${ver.version}`);
} else {
console.log(`Version ${ver.version} - No format detected, skipping XML check`);
@ -289,7 +290,7 @@ tap.test('PDF-12: Cross-version attachment compatibility', async () => {
// Test extraction
try {
const einvoice = await EInvoice.fromPdf(pdfBytes);
await EInvoice.fromPdf(Buffer.from(pdfBytes));
console.log('Cross-version attachment test completed');
} catch (error) {
console.log('Cross-version attachment extraction error:', error.message);
@ -381,7 +382,7 @@ tap.test('PDF-12: Backward compatibility', async () => {
// Verify it can be processed
try {
const einvoice = await EInvoice.fromPdf(pdfBytes);
await EInvoice.fromPdf(Buffer.from(pdfBytes));
console.log('Created backward compatible PDF (1.3 features only)');
} catch (error) {
console.log('Backward compatible PDF processing error:', error.message);
@ -529,7 +530,7 @@ tap.test('PDF-12: Version upgrade scenarios', async () => {
// Test both versions work
try {
const einvoice = await EInvoice.fromPdf(upgradedBytes);
await EInvoice.fromPdf(Buffer.from(upgradedBytes));
console.log('Version upgrade test completed');
} catch (error) {
console.log('Version upgrade processing error:', error.message);
@ -600,7 +601,7 @@ tap.test('PDF-12: Compatibility edge cases', async () => {
const pdfBytes = await edgeCase.test();
try {
const einvoice = await EInvoice.fromPdf(pdfBytes);
await EInvoice.fromPdf(Buffer.from(pdfBytes));
console.log(`[OK] ${edgeCase.name} - Success`);
} catch (extractError) {
console.log(`[OK] ${edgeCase.name} - PDF created, extraction failed (expected):`, extractError.message);