import pytest from reflex.components.core.html import Html from reflex.state import State def test_html_no_children(): with pytest.raises(ValueError): _ = Html.create() def test_html_many_children(): with pytest.raises(ValueError): _ = Html.create("foo", "bar") def test_html_create(): html = Html.create("

Hello !

") assert str(html.dangerouslySetInnerHTML) == '({ ["__html"] : "

Hello !

" })' # pyright: ignore [reportAttributeAccessIssue] assert ( str(html) == '
Hello !

" })}/>' ) def test_html_fstring_create(): class TestState(State): """The app state.""" myvar: str = "Blue" html = Html.create(f"

Hello {TestState.myvar}!

") assert ( str(html.dangerouslySetInnerHTML) # pyright: ignore [reportAttributeAccessIssue] == f'({{ ["__html"] : ("

Hello "+{TestState.myvar!s}+"!

") }})' ) assert ( str(html) == f'
' # pyright: ignore [reportAttributeAccessIssue] )