add test for html issue
This commit is contained in:
parent
5a8ca046de
commit
9deda27450
@ -58,11 +58,7 @@ def test_validate_cond(cond_state: BaseState):
|
||||
|
||||
[true_value_text] = true_value["children"]
|
||||
assert true_value_text["name"] == "RadixThemesText"
|
||||
assert true_value_text["children"][0]["contents"] in (
|
||||
"{`cond is True`}",
|
||||
'{"cond is True"}',
|
||||
"{'cond is True'}",
|
||||
)
|
||||
assert true_value_text["children"][0]["contents"] == '{"cond is True"}'
|
||||
|
||||
# false value
|
||||
false_value = condition["false_value"]
|
||||
@ -70,11 +66,7 @@ def test_validate_cond(cond_state: BaseState):
|
||||
|
||||
[false_value_text] = false_value["children"]
|
||||
assert false_value_text["name"] == "RadixThemesText"
|
||||
assert false_value_text["children"][0]["contents"] in (
|
||||
"{`cond is False`}",
|
||||
'{"cond is False"}',
|
||||
"{'cond is False'}",
|
||||
)
|
||||
assert false_value_text["children"][0]["contents"] == '{"cond is False"}'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from reflex.components.core.html import Html
|
||||
from reflex.state import State
|
||||
|
||||
|
||||
def test_html_no_children():
|
||||
@ -20,3 +21,21 @@ def test_html_create():
|
||||
str(html)
|
||||
== '<div className={"rx-Html"} 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)
|
||||
== f'({{ ["__html"] : ("<p>Hello "+{str(TestState.myvar)}+"!</p>") }})'
|
||||
)
|
||||
assert (
|
||||
str(html)
|
||||
== f'<div className={{"rx-Html"}} dangerouslySetInnerHTML={{{str(html.dangerouslySetInnerHTML)}}}/>'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user