import test from "node:test"; import assert from "node:assert/strict"; import { extractTerminalPreview, removeTerminalPreview } from "../src/_filters/index.js"; test("Terminal previews: extracts rendered Markdown between the leading preview and article headings", () => { const renderedPost = `

Terminal preview

Use the following command:

cat /dispatches/example | head -n 5

Investigation

The public article starts here.

`; assert.equal( extractTerminalPreview(renderedPost), `\n

Use the following command:

\n
cat /dispatches/example | head -n 5
\n ` ); assert.equal( removeTerminalPreview(renderedPost), `\n

Investigation

\n

The public article starts here.

\n ` ); }); test("Terminal previews: ignores missing, misplaced, and malformed preview headings", () => { const regularPost = "

Article

Visible text.

"; const misplacedPreview = "

Article

Terminal preview

Do not extract.

"; assert.equal(extractTerminalPreview(regularPost), ""); assert.equal(removeTerminalPreview(regularPost), regularPost); assert.equal(extractTerminalPreview(misplacedPreview), ""); assert.equal(removeTerminalPreview(misplacedPreview), misplacedPreview); assert.equal(extractTerminalPreview(null), ""); assert.equal(removeTerminalPreview(null), ""); });