test_icon.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import pytest
  2. from reflex.components.lucide.icon import LUCIDE_ICON_LIST, RENAMED_ICONS_05, 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. RENAMED_TAGS = [tag for tag in RENAMED_ICONS_05.items()]
  9. @pytest.mark.parametrize("tag, new_tag", RENAMED_TAGS)
  10. def test_icon_renamed_tags(tag, new_tag):
  11. Icon.create(tag)
  12. # TODO: need a PR so we can pass the following test. Currently it fails and uses the old tag as the import.
  13. # assert icon.alias == f"Lucide{format.to_title_case(new_tag)}Icon"
  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