added invalid html tests

This commit is contained in:
rafaelsideguide 2024-09-03 15:21:45 -03:00
parent d60fa6e084
commit c5e1d77a82
2 changed files with 12 additions and 2 deletions

View File

@ -25,5 +25,16 @@ describe('parseMarkdown', () => {
await expect(parseMarkdown(html)).resolves.toBe(expectedMarkdown); await expect(parseMarkdown(html)).resolves.toBe(expectedMarkdown);
}); });
it('should handle various types of invalid HTML gracefully', async () => {
const invalidHtmls = [
{ html: '<html><p>Unclosed tag', expected: 'Unclosed tag' },
{ html: '<div><span>Missing closing div', expected: 'Missing closing div' },
{ html: '<p><strong>Wrong nesting</em></strong></p>', expected: '**Wrong nesting**' },
{ html: '<a href="http://example.com">Link without closing tag', expected: '[Link without closing tag](http://example.com)' }
];
for (const { html, expected } of invalidHtmls) {
await expect(parseMarkdown(html)).resolves.toBe(expected);
}
});
}); });

View File

@ -8,7 +8,6 @@ import dotenv from 'dotenv';
import { Logger } from './logger'; import { Logger } from './logger';
dotenv.config(); dotenv.config();
// TODO: test with invalid html
// TODO: create a singleton for the converter // TODO: create a singleton for the converter
// TODO: add a timeout to the Go parser // TODO: add a timeout to the Go parser