
* lift node version restraint to allow more recent version if already installed * add node test for latest version * change python version * use purple for debug logs * update workflow * add playwright dev dependency * update workflow * change test * oops * improve test * update test * fix tests * mv units tests to a subfolder * reorganize tests * fix install * update test_state * revert node changes and only keep new tests organization * move integration tests in tests/integration * fix integration workflow * fix dockerfile workflow * fix dockerfile workflow 2 * fix shared_state
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
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("<p>Hello !</p>")
|
|
assert str(html.dangerouslySetInnerHTML) == '({ ["__html"] : "<p>Hello !</p>" })' # type: ignore
|
|
assert (
|
|
str(html)
|
|
== '<div className={"rx-Html prose"} dangerouslySetInnerHTML={({ ["__html"] : "<p>Hello !</p>" })}/>'
|
|
)
|
|
|
|
|
|
def test_html_fstring_create():
|
|
class TestState(State):
|
|
"""The app state."""
|
|
|
|
myvar: str = "Blue"
|
|
|
|
html = Html.create(f"<p>Hello {TestState.myvar}!</p>")
|
|
|
|
assert (
|
|
str(html.dangerouslySetInnerHTML) # type: ignore
|
|
== f'({{ ["__html"] : ("<p>Hello "+{str(TestState.myvar)}+"!</p>") }})'
|
|
)
|
|
assert (
|
|
str(html)
|
|
== f'<div className={{"rx-Html prose"}} dangerouslySetInnerHTML={{{str(html.dangerouslySetInnerHTML)}}}/>' # type: ignore
|
|
)
|