Files
jina-ai--reader/tests/e2e/markdown-options-extended.test.ts
wehub-resource-sync f1ba9c6c36
/ test (push) Failing after 1s
/ build-and-push-to-ghcr (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:23:39 +08:00

71 lines
3.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* E2E tests for additional markdown formatting options:
* markdown.hr custom horizontal rule text
* markdown.linkReferenceStyle full | collapsed | shortcut | discarded
*/
import { describe, it } from 'node:test';
import assert from 'node:assert';
import { crawl, crawlWithHeaders } from '../helpers/client';
describe('markdown.hr', () => {
it('default hr renders as * * *', async () => {
const res = await crawl({ respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
assert.ok(res.body.data.content.includes('* * *'));
});
it('custom hr text replaces default', async () => {
const res = await crawl({ markdown: { hr: '---' }, respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
const content: string = res.body.data.content;
assert.ok(content.includes('---'));
assert.ok(content.includes('Content before the rule.'));
assert.ok(content.includes('Content after the rule.'));
});
it('another custom hr value works', async () => {
const res = await crawl({ markdown: { hr: '***' }, respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
assert.ok(res.body.data.content.includes('***'));
});
it('X-Md-Hr header is respected', async () => {
const res = await crawlWithHeaders({ 'X-Md-Hr': '---' }, { respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
assert.ok(res.body.data.content.includes('---'));
});
});
describe('markdown.linkReferenceStyle (with linkStyle: referenced)', () => {
it('full style produces [text][id] with reference definitions', async () => {
const res = await crawl({ markdown: { linkStyle: 'referenced', linkReferenceStyle: 'full' }, respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
const content: string = res.body.data.content;
assert.match(content, /\[.*?\]\[\d+\]/);
assert.match(content, /\[\d+\]: https?:\/\//);
});
it('collapsed style produces [text][] format', async () => {
const res = await crawl({ markdown: { linkStyle: 'referenced', linkReferenceStyle: 'collapsed' }, respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
const content: string = res.body.data.content;
assert.match(content, /\[.*?\]\[\]/);
});
it('shortcut style produces [text] format', async () => {
const res = await crawl({ markdown: { linkStyle: 'referenced', linkReferenceStyle: 'shortcut' }, respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
const content: string = res.body.data.content;
assert.match(content, /\[.*?\]: https?:\/\//);
});
it('X-Md-Link-Reference-Style header works', async () => {
const res = await crawlWithHeaders({
'X-Md-Link-Style': 'referenced',
'X-Md-Link-Reference-Style': 'full',
}, { respondWith: 'markdown' });
assert.strictEqual(res.status, 200);
assert.match(res.body.data.content, /\[\d+\]: https?:\/\//);
});
});