test_style.py 864 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import pytest
  2. from reflex import style
  3. from reflex.vars import Var
  4. test_style = [
  5. ({"a": 1}, {"a": 1}),
  6. ({"a": Var.create("abc")}, {"a": "abc"}),
  7. ({"test_case": 1}, {"testCase": 1}),
  8. ({"test_case": {"a": 1}}, {"testCase": {"a": 1}}),
  9. ]
  10. @pytest.mark.parametrize(
  11. "style_dict,expected",
  12. test_style,
  13. )
  14. def test_convert(style_dict, expected):
  15. """Test Format a style dictionary.
  16. Args:
  17. style_dict: The style to check.
  18. expected: The expected formatted style.
  19. """
  20. assert style.convert(style_dict) == expected
  21. @pytest.mark.parametrize(
  22. "style_dict,expected",
  23. test_style,
  24. )
  25. def test_create_style(style_dict, expected):
  26. """Test style dictionary.
  27. Args:
  28. style_dict: The style to check.
  29. expected: The expected formatted style.
  30. """
  31. assert style.Style(style_dict) == expected