Files
hyprcrd/public/js/test/markdown-edge.test.js
T
2026-04-09 22:18:45 +02:00

75 lines
2.6 KiB
JavaScript

import { describe, it, expect } from './runner.js';
import { renderMd } from '../modules/markdown.js';
describe('Markdown: Blank Lines', () => {
it('image after blank lines renders', () => {
const html = renderMd('text\n\n\n\n![img](uploads/test.jpg)');
expect(html).toContain('<img');
expect(html).toContain('uploads/test.jpg');
});
it('image after single blank line renders', () => {
const html = renderMd('text\n\n![img](uploads/test.jpg)');
expect(html).toContain('<img');
});
it('image after many blank lines renders', () => {
const html = renderMd('text\n\n\n\n\n\n![img](uploads/test.jpg)');
expect(html).toContain('<img');
});
it('heading after blank lines renders', () => {
const html = renderMd('text\n\n\n\n## Heading');
expect(html).toContain('<h2');
});
it('list after blank lines renders', () => {
const html = renderMd('text\n\n\n\n- item one\n- item two');
expect(html).toContain('<li');
});
it('code block after blank lines renders', () => {
const html = renderMd('text\n\n\n\n```\ncode\n```');
expect(html).toContain('<code');
});
it('hr after blank lines renders', () => {
const html = renderMd('text\n\n\n\n---');
expect(html).toContain('<hr');
});
it('todo after blank lines renders', () => {
const html = renderMd('text\n\n\n\n- [ ] task');
expect(html).toContain('checkbox');
});
it('wiki link after blank lines renders', () => {
const html = renderMd('text\n\n\n\n[[Some Card]]');
expect(html).toContain('card-link');
});
it('gallery block after blank lines renders', () => {
const html = renderMd('text\n\n\n\n```gallery\n![img](test.jpg)\n```');
expect(html).toContain('md-gallery');
});
it('multiple blank lines produce spacing but no broken content', () => {
const html = renderMd('para 1\n\n\n\npara 2\n\n\n\n\npara 3');
// All three paragraphs should render
const pCount = (html.match(/<p>/g) || []).length;
expect(pCount).toBeGreaterThan(1);
});
it('blank lines between images both render', () => {
const html = renderMd('![a](one.jpg)\n\n\n\n![b](two.jpg)');
const imgCount = (html.match(/<img/g) || []).length;
expect(imgCount).toBe(2);
});
it('blank lines dont break bold/italic', () => {
const html = renderMd('**bold text**\n\n\n\n*italic text*');
expect(html).toContain('<strong>bold text</strong>');
expect(html).toContain('<em>italic text</em>');
});
});