reflex/tests/components/base/test_bare.py
2024-08-13 17:02:50 -07:00

29 lines
785 B
Python

import pytest
from reflex.components.base.bare import Bare
from reflex.ivars.base import ImmutableVar
STATE_VAR = ImmutableVar.create_safe("default_state.name")
@pytest.mark.parametrize(
"contents,expected",
[
("hello", '{"hello"}'),
("{}", '{"{}"}'),
(None, '{""}'),
(STATE_VAR, "{default_state.name}"),
# This behavior is now unsupported.
# ("${default_state.name}", "${default_state.name}"),
# ("{state.name}", "{state.name}"),
],
)
def test_fstrings(contents, expected):
"""Test that fstrings are rendered correctly.
Args:
contents: The contents of the component.
expected: The expected output.
"""
comp = Bare.create(contents).render()
assert comp["contents"] == expected