test_icon.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import pytest
  2. from reflex.components.lucide.icon import LUCIDE_ICON_LIST, RENAMED_ICONS_05, Icon
  3. from reflex.components.radix.themes.base import Theme
  4. from reflex.utils import format
  5. @pytest.mark.parametrize("tag", LUCIDE_ICON_LIST)
  6. def test_icon(tag):
  7. icon = Icon.create(tag)
  8. assert icon.alias == f"Lucide{format.to_title_case(tag)}Icon"
  9. RENAMED_TAGS = [tag for tag in RENAMED_ICONS_05.items()]
  10. @pytest.mark.parametrize("tag, new_tag", RENAMED_TAGS)
  11. def test_icon_renamed_tags(tag, new_tag):
  12. Icon.create(tag)
  13. # need a PR so we can pass the following test. Currently it fails and uses the old tag as the import.
  14. # assert icon.alias == f"Lucide{format.to_title_case(new_tag)}Icon"
  15. def test_icon_missing_tag():
  16. with pytest.raises(AttributeError):
  17. _ = Icon.create()
  18. def test_icon_invalid_tag():
  19. with pytest.raises(ValueError):
  20. _ = Icon.create("invalid-tag")
  21. def test_icon_multiple_children():
  22. with pytest.raises(AttributeError):
  23. _ = Icon.create("activity", "child1", "child2")
  24. def test_icon_apply_theme():
  25. ic = Icon.create("activity")
  26. ic._apply_theme(Theme())