test_icon.py 710 B

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