Notes/apps/client/src/services/mermaid.spec.ts
2025-04-18 11:19:43 +03:00

36 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { postprocessMermaidSvg } from "./mermaid.js";
import { trimIndentation } from "@triliumnext/commons";
describe("Mermaid", () => {
it("converts <br> properly", () => {
const before = trimIndentation`\
<g transform="translate(-55.71875, -24)" style="color:black !important" class="label">
<rect></rect>
<foreignObject height="48" width="111.4375">
<div xmlns="http://www.w3.org/1999/xhtml"
style="color: black !important; display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;">
<span class="nodeLabel" style="color:black !important">
<p>Verify Output<br>Against<BR > Criteria</p>
</span>
</div>
</foreignObject>
</g>
`;
const after = trimIndentation`\
<g transform="translate(-55.71875, -24)" style="color:black !important" class="label">
<rect></rect>
<foreignObject height="48" width="111.4375">
<div xmlns="http://www.w3.org/1999/xhtml"
style="color: black !important; display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;">
<span class="nodeLabel" style="color:black !important">
<p>Verify Output<br/>Against<br/> Criteria</p>
</span>
</div>
</foreignObject>
</g>
`;
expect(postprocessMermaidSvg(before)).toBe(after);
});
});