| 123456789101112131415161718192021222324252627282930 |
- import { ReadabilityMarkdownConverter } from '../src//infrastructure/adapters/readability-markdown.converter';
- describe('ReadabilityMarkdownConverter', () => {
- let converter: ReadabilityMarkdownConverter;
- beforeEach(() => {
- converter = new ReadabilityMarkdownConverter();
- });
- it('converts HTML to markdown', async () => {
- const html = '<html><body><h1>Hello</h1><p>World</p></body></html>';
- const result = await converter.convert(html, 'https://example.com');
- expect(result.markdown).toContain('# Hello');
- });
- it('extracts title from document', async () => {
- const html = '<html><head><title>My Title</title></head><body><p>Text</p></body></html>';
- const result = await converter.convert(html, 'https://example.com');
- expect(result.title).toBe('My Title');
- });
- it('falls back to URL as title when no title', async () => {
- const html = '<html><head></head><body><p>Text</p></body></html>';
- const result = await converter.convert(html, 'https://example.com');
- expect(result.title).toBe('https://example.com');
- });
- });
|