import { describe, expect, it } from "vitest"; import { cleanThingiverseMarkdown, htmlToMarkdown } from "../src/services/descriptionMarkdown"; describe("htmlToMarkdown", () => { it("keeps headings, emphasis, lists and step images from a MakerWorld summary", () => { const html = "


See the guide.
';
expect(htmlToMarkdown(html)).toBe(
"See [the guide](https://example.com/guide).\n\n",
);
});
it("writes compact list markers, numbering ordered lists from their start", () => {
expect(htmlToMarkdown('Plate # | Part |
1 | Main Hexa 5 magnets | strong |
| 2 |
Added covers: | ' +
'![]() |
")).toBeNull(); }); }); describe("cleanThingiverseMarkdown", () => { it("leaves plain Markdown alone", () => { expect(cleanThingiverseMarkdown("# Title\n\nA **flexible** dragon.\nSecond line.")).toBe( "# Title\n\nA **flexible** dragon.\nSecond line.", ); }); it("maps inline HTML onto Markdown without losing line breaks", () => { expect( cleanThingiverseMarkdown( 'Line one
\nx & y',
),
).toBe("Line one\nLine **two**\n\n[x](https://x.com) & y");
});
});