/* Copyright 2026 Marimo. All rights reserved. */ import { render } from "@testing-library/react"; import { beforeEach, describe, expect, test, vi } from "vitest"; import { HtmlOutput } from "../HtmlOutput"; // Mock only the useSanitizeHtml hook, use real sanitizeHtml vi.mock("@/plugins/core/sanitize", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, useSanitizeHtml: vi.fn(() => false), }; }); describe("HtmlOutput", () => { beforeEach(() => { vi.clearAllMocks(); }); test("renders HTML content", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`

Hello World

`); }); test("renders inline when inline prop is true", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`
Inline
`); }); test("renders block by default", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`

Block

`); }); test("applies custom className", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`

Test

`); }); test("handles empty html", () => { const { container } = render( , ); expect(container.textContent).toBe(""); }); test("alwaysSanitizeHtml=true sanitizes content", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`

Content

`); }); test("alwaysSanitizeHtml=false allows scripts when useSanitizeHtml=false", () => { const result = render( , ); expect(result.container.firstChild).toMatchInlineSnapshot(`

Content

`); }); });