Leon4gr45/builder
0
1// @vitest-environment jsdom2import { describe, it, expect } from 'vitest';3import { htmlToMarkdown } from '../extract';4 5describe('htmlToMarkdown', () => {6 it('extracts readable content and converts to markdown', () => {7 const html = `<html><body><article><h1>Title</h1><p>Hello <a href="https://x.com">link</a>.</p></article></body></html>`;8 const md = htmlToMarkdown(html, 'https://example.com/post');9 expect(md).toContain('# Title');10 expect(md).toContain('[link](https://x.com)');11 });12 13 it('falls back to raw text when extraction yields nothing', () => {14 const md = htmlToMarkdown('<div>bare</div>', 'https://example.com');15 expect(md.length).toBeGreaterThan(0);16 });17});18 