test_icon.py 815 B

123456789101112131415161718192021222324252627282930313233343536
  1. import pytest
  2. from reflex.components.lucide.icon import (
  3. LUCIDE_ICON_LIST,
  4. LUCIDE_ICON_MAPPING_OVERRIDE,
  5. Icon,
  6. )
  7. from reflex.utils import format
  8. @pytest.mark.parametrize("tag", LUCIDE_ICON_LIST)
  9. def test_icon(tag):
  10. icon = Icon.create(tag)
  11. assert icon.alias == "Lucide" + LUCIDE_ICON_MAPPING_OVERRIDE.get(
  12. tag, f"{format.to_title_case(tag)}Icon"
  13. )
  14. def test_icon_missing_tag():
  15. with pytest.raises(AttributeError):
  16. _ = Icon.create()
  17. def test_icon_invalid_tag():
  18. with pytest.raises(ValueError):
  19. _ = Icon.create("invalid-tag")
  20. def test_icon_multiple_children():
  21. with pytest.raises(AttributeError):
  22. _ = Icon.create("activity", "child1", "child2")
  23. def test_icon_add_style():
  24. ic = Icon.create("activity")
  25. assert ic.add_style() is None