WFDASH-WEBAPP/src/components/markdown.test.tsx
2026-10-01 00:12:56 +02:00

19 lines
758 B
TypeScript

import { describe, it, expect } from "vitest";
import { render } from "@testing-library/react";
import { Markdown } from "./markdown";
const md = "hello ![alt text](https://attacker.example/?d=SECRET) world";
describe("Markdown images", () => {
it("renders an <img> by default (SOP pages unchanged)", () => {
const { container } = render(<Markdown>{md}</Markdown>);
expect(container.querySelector("img")).not.toBeNull();
});
it("renders no <img> when allowImages is false", () => {
const { container } = render(<Markdown allowImages={false}>{md}</Markdown>);
expect(container.querySelector("img")).toBeNull();
expect(container.textContent).toContain("hello");
expect(container.textContent).not.toContain("SECRET");
});
});