26 lines
979 B
JavaScript
26 lines
979 B
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { extract } from '../../lib/ingest/readability.js';
|
|
|
|
const HTML = `
|
|
<html><head><title>Blackflame Notes</title>
|
|
<meta property="og:site_name" content="Hynesy"/>
|
|
</head><body><article>
|
|
<h1>Blackflame Notes</h1>
|
|
<p>An essay on the Cradle aesthetic and the blackflame motif. This is a longer paragraph that gives readability enough text to consider this the main content of the page.</p>
|
|
<p>A second paragraph also part of the article.</p>
|
|
</article></body></html>`;
|
|
|
|
describe('readability.extract', () => {
|
|
it('pulls title and text', () => {
|
|
const out = extract(HTML, 'https://example.com/x');
|
|
expect(out.title).toMatch(/Blackflame/);
|
|
expect(out.textContent).toMatch(/Cradle/);
|
|
expect(out.siteName).toBe('Hynesy');
|
|
});
|
|
|
|
it('returns empty struct when nothing parseable', () => {
|
|
const out = extract('<html></html>', 'https://example.com');
|
|
expect(out.textContent).toBe('');
|
|
});
|
|
});
|