test_html.py 556 B

12345678910111213141516171819202122
  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 (
  13. str(html)
  14. == '<div className={`rx-Html`} dangerouslySetInnerHTML={{"__html": "<p>Hello !</p>"}}/>'
  15. )