{
if (el && !mockUIElement) {
mockUIElement = document.createElement("marimo-ui-element");
mockUIElement.setAttribute("data-testid", "mock-ui-element");
mockUIElement.reset = mockReset;
const inputEl = document.createElement("input");
inputEl.type = "text";
mockUIElement.appendChild(inputEl);
el.appendChild(mockUIElement);
}
}}
/>
,
);
const input = screen.getByRole("textbox");
// Simulate Ctrl+Enter on input
fireEvent.keyDown(input, { key: "Enter", ctrlKey: true });
await waitFor(() => {
expect(setValue).toHaveBeenCalledWith("new-val");
expect(mockReset).toHaveBeenCalled();
});
});
it("does not submit on Shift+Enter", async () => {
const setValue = vi.fn();
const validate = vi.fn().mockResolvedValue(null);
render(
,
);
const input = screen.getByTestId("input");
// Simulate Shift+Enter on input
fireEvent.keyDown(input, { key: "Enter", shiftKey: true });
expect(setValue).not.toHaveBeenCalled();
expect(validate).not.toHaveBeenCalled();
});
});