test_bare.py 606 B

1234567891011121314151617181920212223242526
  1. import pytest
  2. from reflex.components.base.bare import Bare
  3. from reflex.vars.base import Var
  4. STATE_VAR = Var(_js_expr="default_state.name")
  5. @pytest.mark.parametrize(
  6. "contents,expected",
  7. [
  8. ("hello", '"hello"'),
  9. ("{}", '"{}"'),
  10. (None, '""'),
  11. (STATE_VAR, "default_state.name"),
  12. ],
  13. )
  14. def test_fstrings(contents, expected):
  15. """Test that fstrings are rendered correctly.
  16. Args:
  17. contents: The contents of the component.
  18. expected: The expected output.
  19. """
  20. comp = Bare.create(contents).render()
  21. assert comp["contents"] == expected