reflex/tests/units/components/lucide/test_icon.py
Masen Furer 1e7a37bcf9
[ENG-4351] Add mapping for lucide icons (#4622)
* [ENG-4351] Add mapping for lucide icons

For icon names that don't auto-translate to the correct lucide tag name,
provide manual override.

Fix #4621

* account for new mapping in unit tests
2025-01-10 15:23:16 -08:00

37 lines
815 B
Python

import pytest
from reflex.components.lucide.icon import (
LUCIDE_ICON_LIST,
LUCIDE_ICON_MAPPING_OVERRIDE,
Icon,
)
from reflex.utils import format
@pytest.mark.parametrize("tag", LUCIDE_ICON_LIST)
def test_icon(tag):
icon = Icon.create(tag)
assert icon.alias == "Lucide" + LUCIDE_ICON_MAPPING_OVERRIDE.get(
tag, f"{format.to_title_case(tag)}Icon"
)
def test_icon_missing_tag():
with pytest.raises(AttributeError):
_ = Icon.create()
def test_icon_invalid_tag():
with pytest.raises(ValueError):
_ = Icon.create("invalid-tag")
def test_icon_multiple_children():
with pytest.raises(AttributeError):
_ = Icon.create("activity", "child1", "child2")
def test_icon_add_style():
ic = Icon.create("activity")
assert ic.add_style() is None