test_html.py 510 B

12345678910111213141516171819
  1. import pytest
  2. from reflex.components.core.html import Html
  3. def test_html_no_children():
  4. with pytest.raises(ValueError):
  5. _ = Html.create()
  6. def test_html_many_children():
  7. with pytest.raises(ValueError):
  8. _ = Html.create("foo", "bar")
  9. def test_html_create():
  10. html = Html.create("<p>Hello !</p>")
  11. assert str(html.dangerouslySetInnerHTML) == '{"__html": "<p>Hello !</p>"}' # type: ignore
  12. assert str(html) == '<div dangerouslySetInnerHTML={{"__html": "<p>Hello !</p>"}}/>'