reflex/tests/units/components/base/test_bare.py
2024-12-03 22:22:46 +01:00

27 lines
614 B
Python

import pytest
from reflex.components.base.bare import Bare
from reflex.vars.base import Var
STATE_VAR = Var(_js_expr="default_state.name")
@pytest.mark.parametrize(
"contents,expected",
[
("hello", '{"hello"}'),
("{}", '{"{}"}'),
(None, '{""}'),
(STATE_VAR, "{default_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