import { describe, expect, it, vi } from "vitest";
import { sanitizeInteractionHostProps } from "./sanitize-composed-host-props";
describe("sanitizeInteractionHostProps", () => {
it("preserves native interaction props but removes markup", () => {
const onClick = vi.fn();
const onKeyDown = vi.fn();
expect(sanitizeInteractionHostProps({
"aria-label": "Reorder image",
"data-slot": "counterfeit-slot",
DangerouslySetInnerHTML: { __html: "" },
onClick,
onKeyDown,
SrcDOC: "",
tabIndex: 0,
})).toEqual({
"aria-label": "Reorder image",
"data-slot": "counterfeit-slot",
onClick,
onKeyDown,
tabIndex: 0,
});
});
it("preserves semantic and drag interaction props while removing only markup", () => {
const onDragEnter = vi.fn();
expect(sanitizeInteractionHostProps({
contenteditable: "true",
onClick: vi.fn(),
onDragEnter,
onKeyDownCapture: vi.fn(),
role: "button",
tabIndex: 0,
})).toEqual({
contenteditable: "true",
onClick: expect.any(Function),
onDragEnter,
onKeyDownCapture: expect.any(Function),
role: "button",
tabIndex: 0,
});
});
});